From 9d72cede30c1a6986256fba4cac6b28ea963f543 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 5 Dec 2014 10:54:07 +1300 Subject: [PATCH] whitepace y, std is => array( on same line, Reports have always been all over the place on this leading to PRs often going stale --- CRM/Activity/Form/Activity.php | 5 +- CRM/Activity/Import/Form/DataSource.php | 3 +- CRM/Admin/Form/Preferences/Address.php | 6 +- CRM/Admin/Form/Preferences/Campaign.php | 3 +- CRM/Admin/Form/Preferences/Contribute.php | 142 ++-- CRM/Admin/Form/Preferences/Display.php | 3 +- CRM/Admin/Form/Preferences/Event.php | 3 +- CRM/Admin/Form/Preferences/Mailing.php | 38 +- CRM/Admin/Form/Preferences/Member.php | 3 +- CRM/Admin/Form/Preferences/Multisite.php | 3 +- CRM/Admin/Form/Setting/Url.php | 3 +- CRM/Admin/Page/ContactType.php | 12 +- CRM/Campaign/Form/Survey/Results.php | 177 +++-- CRM/Campaign/Form/Task/Interview.php | 24 +- CRM/Contribute/BAO/Contribution.php | 3 +- CRM/Core/BAO/CustomGroup.php | 532 +++++++------ CRM/Custom/Import/Form/DataSource.php | 3 +- CRM/Event/Import/Form/DataSource.php | 3 +- CRM/Logging/ReportSummary.php | 80 +- CRM/Mailing/BAO/Mailing.php | 3 +- CRM/Mailing/Form/Schedule.php | 3 +- CRM/Member/Import/Form/DataSource.php | 6 +- CRM/Report/Form.php | 707 +++++++++++------- CRM/Report/Form/Activity.php | 465 ++++++------ CRM/Report/Form/ActivitySummary.php | 3 +- CRM/Report/Form/Campaign/SurveyDetails.php | 298 +++++--- CRM/Report/Form/Case/Demographics.php | 150 ++-- CRM/Report/Form/Case/Detail.php | 199 ++--- CRM/Report/Form/Case/Summary.php | 165 ++-- CRM/Report/Form/Case/TimeSpent.php | 143 ++-- CRM/Report/Form/Contact/CurrentEmployer.php | 158 ++-- CRM/Report/Form/Contact/Detail.php | 335 +++++---- CRM/Report/Form/Contact/Log.php | 100 ++- CRM/Report/Form/Contact/Relationship.php | 233 +++--- CRM/Report/Form/Contact/Summary.php | 214 +++--- CRM/Report/Form/Contribute/Bookkeeping.php | 159 ++-- CRM/Report/Form/Contribute/Detail.php | 595 ++++++++------- CRM/Report/Form/Contribute/History.php | 350 ++++----- .../Form/Contribute/HouseholdSummary.php | 40 +- CRM/Report/Form/Contribute/Lybunt.php | 262 +++---- CRM/Report/Form/Contribute/PCP.php | 131 ++-- CRM/Report/Form/Contribute/Repeat.php | 214 +++--- CRM/Report/Form/Contribute/SoftCredit.php | 161 ++-- CRM/Report/Form/Contribute/Summary.php | 474 ++++++------ CRM/Report/Form/Contribute/Sybunt.php | 285 +++---- CRM/Report/Form/Contribute/TopDonor.php | 214 +++--- CRM/Report/Form/Event/IncomeCountSummary.php | 41 +- .../Form/Event/ParticipantListCount.php | 223 +++--- CRM/Report/Form/Event/ParticipantListing.php | 263 +++---- CRM/Report/Form/Event/Summary.php | 50 +- CRM/Report/Form/Extended.php | 332 ++++---- CRM/Report/Form/Grant/Detail.php | 143 ++-- CRM/Report/Form/Grant/Statistics.php | 190 +++-- CRM/Report/Form/Mailing/Bounce.php | 51 +- CRM/Report/Form/Mailing/Clicks.php | 39 +- CRM/Report/Form/Mailing/Detail.php | 152 ++-- CRM/Report/Form/Mailing/Opened.php | 42 +- CRM/Report/Form/Member/ContributionDetail.php | 598 ++++++++------- CRM/Report/Form/Member/Lapse.php | 124 ++- CRM/Report/Form/Member/Summary.php | 186 ++--- CRM/Report/Form/Membership/Summary.php | 115 ++- CRM/Report/Form/Pledge/Detail.php | 314 ++++---- CRM/Report/Form/Pledge/Pbnp.php | 116 ++- CRM/Report/Form/Pledge/Summary.php | 256 +++---- CRM/Report/Form/Walklist/Walklist.php | 77 +- CRM/SMS/Form/Schedule.php | 3 +- CRM/Upgrade/Incremental/php/FourOne.php | 96 +-- CRM/Upgrade/Incremental/php/FourTwo.php | 9 +- CRM/Utils/Token.php | 3 +- CRM/Widget/Widget.php | 18 +- 70 files changed, 5398 insertions(+), 5156 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 33e6d222fb..455ea63099 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -145,10 +145,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { 'location' => array( 'type' => 'text', 'label' => ts('Location'), - 'attributes' => - CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', - 'location' - ), + 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'), 'required' => FALSE ), 'details' => array( diff --git a/CRM/Activity/Import/Form/DataSource.php b/CRM/Activity/Import/Form/DataSource.php index 692887f571..3690335b4a 100644 --- a/CRM/Activity/Import/Form/DataSource.php +++ b/CRM/Activity/Import/Form/DataSource.php @@ -102,8 +102,7 @@ class CRM_Activity_Import_Form_DataSource extends CRM_Core_Form { } $this->setDefaults(array( - 'onDuplicate' => - CRM_Import_Parser::DUPLICATE_SKIP, + 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, )); //build date formats diff --git a/CRM/Admin/Form/Preferences/Address.php b/CRM/Admin/Form/Preferences/Address.php index 285827eff6..b3a7424c51 100644 --- a/CRM/Admin/Form/Preferences/Address.php +++ b/CRM/Admin/Form/Preferences/Address.php @@ -46,8 +46,7 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { '' => '- select -') + CRM_Core_SelectValues::addressProvider(); $this->_varNames = array( - CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( 'address_options' => array( 'html_type' => 'checkboxes', 'title' => ts('Address Fields'), @@ -66,8 +65,7 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { 'weight' => 3, ), ), - CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => array( 'address_standardization_provider' => array( 'html_type' => 'select', 'title' => ts('Provider'), diff --git a/CRM/Admin/Form/Preferences/Campaign.php b/CRM/Admin/Form/Preferences/Campaign.php index 1a907fb11e..adb3cd475c 100644 --- a/CRM/Admin/Form/Preferences/Campaign.php +++ b/CRM/Admin/Form/Preferences/Campaign.php @@ -41,8 +41,7 @@ class CRM_Admin_Form_Preferences_Campaign extends CRM_Admin_Form_Preferences { function preProcess() { CRM_Utils_System::setTitle(ts('CiviCampaign Component Settings')); $this->_varNames = array( - CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array( 'tag_unconfirmed' => array( 'html_type' => 'text', 'title' => ts('Tag for Unconfirmed Petition Signers'), diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index 8e5eea9a50..15894d8f86 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -16,75 +16,70 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { $config = CRM_Core_Config::singleton(); CRM_Utils_System::setTitle(ts('CiviContribute Component Settings')); $this->_varNames = array( - CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME => - array( - 'invoice_prefix' => - array( - 'html_type' => 'text', - 'title' => ts('Invoice Prefix'), - 'weight' => 1, - 'description' => ts('Enter prefix to be display on PDF for invoice'), - ), - 'credit_notes_prefix' => - array( - 'html_type' => 'text', - 'title' => ts('Credit Notes Prefix'), - 'weight' => 2, - 'description' => ts('Enter prefix to be display on PDF for credit notes.'), - ), - 'due_date' => - array( - 'html_type' => 'text', - 'title' => ts('Due Date'), - 'weight' => 3, - ), - 'due_date_period' => - array( - 'html_type' => 'select', - 'title' => ts('For transmission'), - 'weight' => 4, - 'description' => ts('Select the interval for due date.'), - 'option_values' => - array( - 'select' => ts('- select -'), - 'days' => ts('Days'), - 'months' => ts('Months'), - 'years' => ts('Years'), + CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME => array( + 'invoice_prefix' => array( + 'html_type' => 'text', + 'title' => ts('Invoice Prefix'), + 'weight' => 1, + 'description' => ts('Enter prefix to be display on PDF for invoice'), ), - ), - 'notes' => - array( - 'html_type' => 'wysiwyg', - 'title' => ts('Notes or Standard Terms'), - 'weight' => 5, - 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '), - 'attributes' => array('rows' => 2, 'cols' => 40), - ), - 'is_email_pdf' => - array( - 'html_type' => 'checkbox', - 'title' => ts('Automatically email invoice when user purchases online'), - 'weight' => 6, - ), - 'tax_term' => - array( - 'html_type' => 'text', - 'title' => ts('Tax Term'), - 'weight' => 7, - ), - 'tax_display_settings'=> - array( - 'html_type' => 'select', - 'title' => ts('Tax Display Settings'), - 'weight' => 8, - 'option_values' => - array( - 'Do_not_show' => ts('Do not show breakdown, only show total -i.e '.$config->defaultCurrencySymbol.'120.00'), - 'Inclusive' => ts('Show [tax term] inclusive price - i.e. '.$config->defaultCurrencySymbol.'120.00 (includes [tax term] of '.$config->defaultCurrencySymbol.'20.00)'), - 'Exclusive' => ts('Show [tax term] exclusive price - i.e. '.$config->defaultCurrencySymbol.'100.00 + '.$config->defaultCurrencySymbol.'20.00 [tax term]'), + 'credit_notes_prefix' => array( + 'html_type' => 'text', + 'title' => ts('Credit Notes Prefix'), + 'weight' => 2, + 'description' => ts('Enter prefix to be display on PDF for credit notes.'), + ), + 'due_date' => array( + 'html_type' => 'text', + 'title' => ts('Due Date'), + 'weight' => 3, + ), + 'due_date_period' => array( + 'html_type' => 'select', + 'title' => ts('For transmission'), + 'weight' => 4, + 'description' => ts('Select the interval for due date.'), + 'option_values' => array( + 'select' => ts('- select -'), + 'days' => ts('Days'), + 'months' => ts('Months'), + 'years' => ts('Years'), + ), + ), + 'notes' => array( + 'html_type' => 'wysiwyg', + 'title' => ts('Notes or Standard Terms'), + 'weight' => 5, + 'description' => ts('Enter note or message to be displayed on PDF invoice or credit notes '), + 'attributes' => array('rows' => 2, 'cols' => 40), + ), + 'is_email_pdf' => array( + 'html_type' => 'checkbox', + 'title' => ts('Automatically email invoice when user purchases online'), + 'weight' => 6, + ), + 'tax_term' => array( + 'html_type' => 'text', + 'title' => ts('Tax Term'), + 'weight' => 7, + ), + 'tax_display_settings' => array( + 'html_type' => 'select', + 'title' => ts('Tax Display Settings'), + 'weight' => 8, + 'option_values' => array( + 'Do_not_show' => ts('Do not show breakdown, only show total -i.e ' . + $config->defaultCurrencySymbol . '120.00'), + 'Inclusive' => ts('Show [tax term] inclusive price - i.e. ' . + $config->defaultCurrencySymbol . + '120.00 (includes [tax term] of ' . + $config->defaultCurrencySymbol . '20.00)'), + 'Exclusive' => ts('Show [tax term] exclusive price - i.e. ' . + $config->defaultCurrencySymbol . '100.00 + ' . + $config->defaultCurrencySymbol . '20.00 [tax term]'), + ), ), ), - ), ); parent::preProcess(); } @@ -109,7 +104,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { * @return void */ function setDefaultValues() { - $defaults = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings'); + $defaults = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); return $defaults; } @@ -134,14 +129,19 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { if (isset($params['invoicing'])) { $value = array($setKey => $optionValues[$setKey]); - $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) . CRM_Core_DAO::VALUE_SEPARATOR; - CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'] . $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options'); + $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) . + CRM_Core_DAO::VALUE_SEPARATOR; + CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'] . + $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options'); } else { $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1)); - $invoiceKey = array_search ($setKey, $setting); + $invoiceKey = array_search($setKey, $setting); unset($setting[$invoiceKey]); - $settingName = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) . CRM_Core_DAO::VALUE_SEPARATOR; + $settingName = CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) . + CRM_Core_DAO::VALUE_SEPARATOR; CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options'); } } diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 77a354dab5..0eeeb9bb5c 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -42,8 +42,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { CRM_Utils_System::setTitle(ts('Settings - Display Preferences')); $this->_varNames = array( - CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( 'contact_view_options' => array( 'html_type' => 'checkboxes', 'title' => ts('Viewing Contacts'), diff --git a/CRM/Admin/Form/Preferences/Event.php b/CRM/Admin/Form/Preferences/Event.php index f5e36d43b2..52b7d1ff61 100644 --- a/CRM/Admin/Form/Preferences/Event.php +++ b/CRM/Admin/Form/Preferences/Event.php @@ -48,8 +48,7 @@ class CRM_Admin_Form_Preferences_Event extends CRM_Admin_Form_Preferences { $optionValues[$i] = $i; } $this->_varNames = array( - CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array( 'enable_cart' => array( 'html_type' => 'checkbox', 'title' => ts('Use Shopping Cart Style Event Registration'), diff --git a/CRM/Admin/Form/Preferences/Mailing.php b/CRM/Admin/Form/Preferences/Mailing.php index e21570426d..7d3a2ae3f9 100644 --- a/CRM/Admin/Form/Preferences/Mailing.php +++ b/CRM/Admin/Form/Preferences/Mailing.php @@ -41,80 +41,68 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences { function preProcess() { CRM_Utils_System::setTitle(ts('CiviMail Component Settings')); $this->_varNames = array( - CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => - array( - 'profile_double_optin' => - array( + CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array( + 'profile_double_optin' => array( 'html_type' => 'checkbox', 'title' => ts('Enable Double Opt-in for Profile Group(s) field'), 'weight' => 1, 'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'), ), - 'profile_add_to_group_double_optin' => - array( + 'profile_add_to_group_double_optin' => array( 'html_type' => 'checkbox', 'title' => ts('Enable Double Opt-in for Profiles which use the "Add to Group" setting'), 'weight' => 2, 'description' => ts('When CiviMail is enabled and a profile uses the "Add to Group" setting, users who complete the profile form will receive a confirmation email. They must respond (opt-in) before they are added to the group.'), ), - 'track_civimail_replies' => - array( + 'track_civimail_replies' => array( 'html_type' => 'checkbox', 'title' => ts('Track replies using VERP in Reply-To header'), 'weight' => 3, 'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To.'), ), - 'civimail_workflow' => - array( + 'civimail_workflow' => array( 'html_type' => 'checkbox', 'title' => ts('Enable workflow support for CiviMail'), 'weight' => 4, 'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'), ), - 'civimail_multiple_bulk_emails' => - array( + 'civimail_multiple_bulk_emails' => array( 'html_type' => 'checkbox', 'title' => ts('Enable multiple bulk email address for a contact.'), 'weight' => 5, 'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact.'), ), - 'civimail_server_wide_lock' => - array( + 'civimail_server_wide_lock' => array( 'html_type' => 'checkbox', 'title' => ts('Enable global server wide lock for CiviMail'), 'weight' => 6, 'description' => NULL, ), - 'include_message_id' => - array( + 'include_message_id' => array( 'html_type' => 'checkbox', 'title' => ts('Enable CiviMail to generate Message-ID header'), 'weight' => 7, 'description' => NULL, ), - 'write_activity_record' => - array( + 'write_activity_record' => array( 'html_type' => 'checkbox', 'title' => ts('Enable CiviMail to create activities on delivery'), 'weight' => 8, 'description' => NULL, ), - 'disable_mandatory_tokens_check' => - array( + 'disable_mandatory_tokens_check' => array( 'html_type' => 'checkbox', 'title' => ts('Disable check for mandatory tokens'), 'weight' => 9, 'description' => ts('Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.'), ), - 'dedupe_email_default' => - array( + 'dedupe_email_default' => array( 'html_type' => 'checkbox', 'title' => ts('CiviMail dedupes e-mail addresses by default'), 'weight' => 10, 'description' => NULL, ), - 'hash_mailing_url' => - array( + 'hash_mailing_url' => array( 'html_type' => 'checkbox', 'title' => ts('Hashed Mailing URL\'s'), 'weight' => 11, @@ -150,4 +138,4 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences { parent::postProcess(); } -} \ No newline at end of file +} diff --git a/CRM/Admin/Form/Preferences/Member.php b/CRM/Admin/Form/Preferences/Member.php index bb51ee6f11..0061525157 100644 --- a/CRM/Admin/Form/Preferences/Member.php +++ b/CRM/Admin/Form/Preferences/Member.php @@ -41,8 +41,7 @@ class CRM_Admin_Form_Preferences_Member extends CRM_Admin_Form_Preferences { function preProcess() { CRM_Utils_System::setTitle(ts('CiviMember Component Settings')); $this->_varNames = array( - CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array( 'default_renewal_contribution_page' => array( 'html_type' => 'select', 'title' => ts('Default online membership renewal page'), diff --git a/CRM/Admin/Form/Preferences/Multisite.php b/CRM/Admin/Form/Preferences/Multisite.php index 987cd26661..1a9d12dcda 100644 --- a/CRM/Admin/Form/Preferences/Multisite.php +++ b/CRM/Admin/Form/Preferences/Multisite.php @@ -42,8 +42,7 @@ class CRM_Admin_Form_Preferences_Multisite extends CRM_Admin_Form_Preferences { $msDoc = CRM_Utils_System::docURL2('Multi Site Installation', NULL, NULL, NULL, NULL, "wiki"); CRM_Utils_System::setTitle(ts('Multi Site Settings')); $this->_varNames = array( - CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array( 'is_enabled' => array( 'html_type' => 'checkbox', 'title' => ts('Enable Multi Site Configuration'), diff --git a/CRM/Admin/Form/Setting/Url.php b/CRM/Admin/Form/Setting/Url.php index 9a46f9fdd3..1d531c9724 100644 --- a/CRM/Admin/Form/Setting/Url.php +++ b/CRM/Admin/Form/Setting/Url.php @@ -85,8 +85,7 @@ class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting { ); if (!CRM_Utils_System::checkURL($url, TRUE)) { $errors = array( - 'enableSSL' => - ts('You need to set up a secure server before you can use the Force Secure URLs option'), + 'enableSSL' => ts('You need to set up a secure server before you can use the Force Secure URLs option'), ); return $errors; } diff --git a/CRM/Admin/Page/ContactType.php b/CRM/Admin/Page/ContactType.php index 47010c6217..95538f1804 100644 --- a/CRM/Admin/Page/ContactType.php +++ b/CRM/Admin/Page/ContactType.php @@ -65,27 +65,23 @@ class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic { function &links() { if (!(self::$_links)) { self::$_links = array( - CRM_Core_Action::UPDATE => - array( + CRM_Core_Action::UPDATE => array( 'name' => ts('Edit'), 'url' => 'civicrm/admin/options/subtype', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Contact Type'), ), - CRM_Core_Action::DISABLE => - array( + CRM_Core_Action::DISABLE => array( 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Contact Type'), ), - CRM_Core_Action::ENABLE => - array( + CRM_Core_Action::ENABLE => array( 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Contact Type'), ), - CRM_Core_Action::DELETE => - array( + CRM_Core_Action::DELETE => array( 'name' => ts('Delete'), 'url' => 'civicrm/admin/options/subtype', 'qs' => 'action=delete&id=%%id%%', diff --git a/CRM/Campaign/Form/Survey/Results.php b/CRM/Campaign/Form/Survey/Results.php index 0980ddf94e..87cbab0e17 100644 --- a/CRM/Campaign/Form/Survey/Results.php +++ b/CRM/Campaign/Form/Survey/Results.php @@ -64,10 +64,10 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $this->set('values', $this->_values); } - $query = "SELECT MAX(id) as id, title FROM civicrm_report_instance WHERE name = %1"; - $params = array( 1 => array("survey_{$this->_surveyId}",'String') ); + $query = "SELECT MAX(id) as id, title FROM civicrm_report_instance WHERE name = %1"; + $params = array(1 => array("survey_{$this->_surveyId}", 'String')); $result = CRM_Core_DAO::executeQuery($query, $params); - if ( $result->fetch() ) { + if ($result->fetch()) { $this->_reportId = $result->id; $this->_reportTitle = $result->title; } @@ -112,14 +112,16 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $optionTypes = array('1' => ts('Create new result set')); } else { - $optionTypes = array('1' => ts('Create new result set'), + $optionTypes = array( + '1' => ts('Create new result set'), '2' => ts('Use existing result set'), ); $this->add('select', 'option_group_id', ts('Select Result Set'), array( - '' => ts('- select -')) + $optionGroups, FALSE, + '' => ts('- select -') + ) + $optionGroups, FALSE, array('onChange' => 'loadOptionGroup( )') ); } @@ -128,7 +130,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { ts('Survey Responses'), $optionTypes, array( - 'onclick' => "showOptionSelect();"), '
', TRUE + 'onclick' => "showOptionSelect();" + ), '
', TRUE ); if (empty($optionGroups) || empty($this->_values['result_id'])) { @@ -137,8 +140,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { elseif (!empty($this->_values['result_id'])) { $this->setdefaults(array( 'option_type' => 2, - 'option_group_id' => $this->_values['result_id'], - )); + 'option_group_id' => $this->_values['result_id'], + )); } // form fields of Custom Option rows @@ -175,7 +178,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $optionAttributes['weight'] ); - $this->add('text', 'option_interval[' . $i . ']', ts('Recontact Interval'), + $this->add('text', 'option_interval[' . $i . + ']', ts('Recontact Interval'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency') ); @@ -190,12 +194,15 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $this->addElement('checkbox', 'create_report', ts('Create Report')); $this->addElement('text', 'report_title', ts('Report Title')); - if( $this->_reportId){ + if ($this->_reportId) { $this->freeze('create_report'); $this->freeze('report_title'); } - $this->addFormRule(array('CRM_Campaign_Form_Survey_Results', 'formRule'), $this); + $this->addFormRule(array( + 'CRM_Campaign_Form_Survey_Results', + 'formRule' + ), $this); parent::buildQuickForm(); } @@ -218,7 +225,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { } if ( - $fields['option_type'] == 2 && empty($fields['option_group_id'])) { + $fields['option_type'] == 2 && empty($fields['option_group_id']) + ) { $errors['option_group_id'] = ts("Please select a Survey Result Set."); return $errors; } @@ -237,12 +245,15 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $nextIndex = $start + 1; while ($nextIndex <= self::NUM_OPTION) { - if ($fields['option_value'][$start] == $fields['option_value'][$nextIndex] && + if ($fields['option_value'][$start] == + $fields['option_value'][$nextIndex] && !empty($fields['option_value'][$nextIndex]) ) { - $errors['option_value[' . $start . ']'] = ts('Duplicate Option values'); - $errors['option_value[' . $nextIndex . ']'] = ts('Duplicate Option values'); + $errors['option_value[' . $start . + ']'] = ts('Duplicate Option values'); + $errors['option_value[' . $nextIndex . + ']'] = ts('Duplicate Option values'); $_flagOption = 1; } $nextIndex++; @@ -263,9 +274,14 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $nextIndex = $start + 1; while ($nextIndex <= self::NUM_OPTION) { - if ($fields['option_label'][$start] == $fields['option_label'][$nextIndex] && !empty($fields['option_label'][$nextIndex])) { - $errors['option_label[' . $start . ']'] = ts('Duplicate Option label'); - $errors['option_label[' . $nextIndex . ']'] = ts('Duplicate Option label'); + if ($fields['option_label'][$start] == + $fields['option_label'][$nextIndex] && + !empty($fields['option_label'][$nextIndex]) + ) { + $errors['option_label[' . $start . + ']'] = ts('Duplicate Option label'); + $errors['option_label[' . $nextIndex . + ']'] = ts('Duplicate Option label'); $_flagOption = 1; } $nextIndex++; @@ -278,7 +294,8 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { for ($i = 1; $i <= self::NUM_OPTION; $i++) { if (!$fields['option_label'][$i]) { if ($fields['option_value'][$i]) { - $errors['option_label[' . $i . ']'] = ts('Option label cannot be empty'); + $errors['option_label[' . $i . + ']'] = ts('Option label cannot be empty'); $_flagOption = 1; } else { @@ -287,14 +304,18 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { } elseif (!strlen(trim($fields['option_value'][$i]))) { if (!$fields['option_value'][$i]) { - $errors['option_value[' . $i . ']'] = ts('Option value cannot be empty'); + $errors['option_value[' . $i . + ']'] = ts('Option value cannot be empty'); $_flagOption = 1; } } - if (!empty($fields['option_interval'][$i]) && !CRM_Utils_Rule::integer($fields['option_interval'][$i])) { + if (!empty($fields['option_interval'][$i]) && + !CRM_Utils_Rule::integer($fields['option_interval'][$i]) + ) { $_flagOption = 1; - $errors['option_interval[' . $i . ']'] = ts('Please enter a valid integer.'); + $errors['option_interval[' . $i . + ']'] = ts('Please enter a valid integer.'); } $showBlocks = 'optionField_' . $i; @@ -338,7 +359,9 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $updateResultSet = FALSE; $resultSetOptGrpId = NULL; - if ((CRM_Utils_Array::value('option_type', $params) == 2) && !empty($params['option_group_id'])) { + if ((CRM_Utils_Array::value('option_type', $params) == 2) && + !empty($params['option_group_id']) + ) { $updateResultSet = TRUE; $resultSetOptGrpId = $params['option_group_id']; } @@ -382,7 +405,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $optionValue->save(); // using is_numeric since 0 is a valid value for option_interval - if ( is_numeric($params['option_interval'][$k])) { + if (is_numeric($params['option_interval'][$k])) { $recontactInterval[$optionValue->label] = $params['option_interval'][$k]; } } @@ -392,61 +415,72 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $survey = CRM_Campaign_BAO_Survey::create($params); // create report if required. - if ( !$this->_reportId && $survey->id && !empty($params['create_report'])) { + if (!$this->_reportId && $survey->id && !empty($params['create_report'])) { $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $activityStatus = array_flip($activityStatus); $this->_params = - array( 'name' => "survey_{$survey->id}", - 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], - 'status_id_op' => 'eq', - 'status_id_value' => $activityStatus['Scheduled'], // reserved status - 'survey_id_value' => array($survey->id), - 'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'), - ); + array( + 'name' => "survey_{$survey->id}", + 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], + 'status_id_op' => 'eq', + 'status_id_value' => $activityStatus['Scheduled'], // reserved status + 'survey_id_value' => array($survey->id), + 'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'), + ); //Default value of order by $this->_params['order_bys'] = array( - 1 => - array( - 'column' => 'sort_name', - 'order' => 'ASC' - ), - ); + 1 => array( + 'column' => 'sort_name', + 'order' => 'ASC' + ), + ); // for WalkList or default - $displayFields = array('id', 'sort_name', 'result', 'street_number','street_name','street_unit','survey_response'); - if ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_values['activity_type_id'] ) { + $displayFields = array( + 'id', + 'sort_name', + 'result', + 'street_number', + 'street_name', + 'street_unit', + 'survey_response' + ); + if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == + $this->_values['activity_type_id'] + ) { $this->_params['order_bys'] = array( - 1 => - array( - 'column' => 'street_name', - 'order' => 'ASC' - ), - 2 => - array( - 'column' => 'street_number_odd_even', - 'order' => 'ASC' - ), - 3 => - array( - 'column' => 'street_number', - 'order' => 'ASC' - ), - 4 => - array( - 'column' => 'sort_name', - 'order' => 'ASC' - ), - ); + 1 => array( + 'column' => 'street_name', + 'order' => 'ASC' + ), + 2 => array( + 'column' => 'street_number_odd_even', + 'order' => 'ASC' + ), + 3 => array( + 'column' => 'street_number', + 'order' => 'ASC' + ), + 4 => array( + 'column' => 'sort_name', + 'order' => 'ASC' + ), + ); } - elseif ( CRM_Core_OptionGroup::getValue('activity_type','PhoneBank') == $this->_values['activity_type_id'] ) { + elseif (CRM_Core_OptionGroup::getValue('activity_type', 'PhoneBank') == + $this->_values['activity_type_id'] + ) { array_push($displayFields, 'phone'); } - elseif ((CRM_Core_OptionGroup::getValue('activity_type','Survey') == $this->_values['activity_type_id']) || - (CRM_Core_OptionGroup::getValue('activity_type','Canvass') == $this->_values['activity_type_id']) ) { - array_push($displayFields, 'phone','city','state_province_id','postal_code','email'); + elseif ((CRM_Core_OptionGroup::getValue('activity_type', 'Survey') == + $this->_values['activity_type_id']) || + (CRM_Core_OptionGroup::getValue('activity_type', 'Canvass') == + $this->_values['activity_type_id']) + ) { + array_push($displayFields, 'phone', 'city', 'state_province_id', 'postal_code', 'email'); } - foreach($displayFields as $key){ + foreach ($displayFields as $key) { $this->_params['fields'][$key] = 1; } $this->_createNew = TRUE; @@ -454,11 +488,16 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { CRM_Report_Form_Instance::postProcess($this, FALSE); $query = "SELECT MAX(id) FROM civicrm_report_instance WHERE name = %1"; - $reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$survey->id}",'String'))); + $reportID = CRM_Core_DAO::singleValueQuery($query, array( + 1 => array( + "survey_{$survey->id}", + 'String' + ) + )); if ($reportID) { - $url = CRM_Utils_System::url("civicrm/report/instance/{$reportID}",'reset=1'); + $url = CRM_Utils_System::url("civicrm/report/instance/{$reportID}", 'reset=1'); $status = ts("A Survey Detail Report %2 has been created.", - array(1 => $url, 2 => $this->_params['title'])); + array(1 => $url, 2 => $this->_params['title'])); } } diff --git a/CRM/Campaign/Form/Task/Interview.php b/CRM/Campaign/Form/Task/Interview.php index b0721677df..2fd9b526ce 100755 --- a/CRM/Campaign/Form/Task/Interview.php +++ b/CRM/Campaign/Form/Task/Interview.php @@ -109,23 +109,19 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task { elseif ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) { $orderByParams = array( - 1 => - array( + 1 => array( 'column' => 'civicrm_address.street_name', 'order' => 'ASC', ), - 2 => - array( + 2 => array( 'column' => 'civicrm_address.street_number%2', 'order' => 'ASC', ), - 3 => - array( + 3 => array( 'column' => 'civicrm_address.street_number', 'order' => 'ASC', ), - 4 => - array( + 4 => array( 'column' => 'contact_a.sort_name', 'order' => 'ASC', ), @@ -408,23 +404,19 @@ WHERE {$clause} if ( CRM_Core_OptionGroup::getValue('activity_type','WalkList') == $this->_surveyDetails['activity_type_id'] ) { $defaults['order_bys'] = array( - 1 => - array( + 1 => array( 'column' => 'civicrm_address.street_name', 'order' => 'ASC', ), - 2 => - array( + 2 => array( 'column' => 'civicrm_address.street_number%2', 'order' => 'ASC', ), - 3 => - array( + 3 => array( 'column' => 'civicrm_address.street_number', 'order' => 'ASC', ), - 4 => - array( + 4 => array( 'column' => 'contact_a.sort_name', 'order' => 'ASC', ), diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index eb5099e629..d03cb0aa2b 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -652,8 +652,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { ); $contributionRecurId = array( - 'contribution_recur_id' => - array( + 'contribution_recur_id' => array( 'title' => ts('Recurring Contributions ID'), 'name' => 'contribution_recur_id', 'where' => 'civicrm_contribution.contribution_recur_id', diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 0a4de2ac9f..6646cd8200 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -63,12 +63,12 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $group->title = $params['title']; if (in_array($params['extends'][0], - array( - 'ParticipantRole', - 'ParticipantEventName', - 'ParticipantEventType', - ) - )) { + array( + 'ParticipantRole', + 'ParticipantEventName', + 'ParticipantEventType', + ) + )) { $group->extends = 'Participant'; } else { @@ -94,10 +94,14 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { if (!CRM_Utils_System::isNull($extendsChildType)) { $extendsChildType = implode(CRM_Core_DAO::VALUE_SEPARATOR, $extendsChildType); if (CRM_Utils_Array::value(0, $params['extends']) == 'Relationship') { - $extendsChildType = str_replace(array('_a_b', '_b_a'), array('', ''), $extendsChildType); + $extendsChildType = str_replace(array('_a_b', '_b_a'), array( + '', + '' + ), $extendsChildType); } if (substr($extendsChildType, 0, 1) != CRM_Core_DAO::VALUE_SEPARATOR) { - $extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . CRM_Core_DAO::VALUE_SEPARATOR; + $extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . + CRM_Core_DAO::VALUE_SEPARATOR; } } else { @@ -112,7 +116,15 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $oldWeight = 0; } $group->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomGroup', $oldWeight, CRM_Utils_Array::value('weight', $params, FALSE)); - $fields = array('style', 'collapse_display', 'collapse_adv_display', 'help_pre', 'help_post', 'is_active', 'is_multiple'); + $fields = array( + 'style', + 'collapse_display', + 'collapse_adv_display', + 'help_pre', + 'help_post', + 'is_active', + 'is_multiple' + ); foreach ($fields as $field) { $group->$field = CRM_Utils_Array::value($field, $params, FALSE); } @@ -214,7 +226,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { /** * Fetch object based on array of properties * - * @param array $params (reference ) an assoc array of name/value pairs + * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the flattened values * * @return CRM_Core_DAO_CustomGroup object @@ -228,8 +240,8 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { /** * Update the is_active flag in the db * - * @param int $id id of the database record - * @param boolean $is_active value we want to set the is_active field + * @param int $id id of the database record + * @param boolean $is_active value we want to set the is_active field * * @return Object DAO object on sucess, null otherwise * @static @@ -257,9 +269,11 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { */ public static function hasCustomGroup($extends, $columnId, $columnValue) { $dao = new CRM_Core_DAO_CustomGroup(); - $dao->extends = $extends; + $dao->extends = $extends; $dao->extends_entity_column_id = $columnId; - $escapedValue = CRM_Core_DAO::VALUE_SEPARATOR . CRM_Core_DAO::escapeString($columnValue) . CRM_Core_DAO::VALUE_SEPARATOR; + $escapedValue = + CRM_Core_DAO::VALUE_SEPARATOR . CRM_Core_DAO::escapeString($columnValue) . + CRM_Core_DAO::VALUE_SEPARATOR; $dao->whereAdd("extends_entity_column_value LIKE \"%$escapedValue%\""); //$dao->extends_entity_column_value = $columnValue; return $dao->find() ? TRUE : FALSE; @@ -270,6 +284,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { * If none found, create one. * * @param int $activityTypeId + * * @return bool TRUE if a group is found or created; FALSE on error */ public static function autoCreateByActivityType($activityTypeId) { @@ -287,7 +302,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'is_active' => 1, ); $result = civicrm_api('CustomGroup', 'create', $params); - return ! $result['is_error']; + return !$result['is_error']; } /** @@ -322,9 +337,9 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $entityType, &$form, $entityID = NULL, - $groupID = NULL, - $subType = NULL, - $subName = NULL, + $groupID = NULL, + $subType = NULL, + $subName = NULL, $fromCache = TRUE, $onlySubType = NULL ) { @@ -338,8 +353,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { // using tableData to build the queryString $tableData = array( - 'civicrm_custom_field' => - array( + 'civicrm_custom_field' => array( 'id', 'label', 'column_name', @@ -359,8 +373,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'option_group_id', 'in_selector' ), - 'civicrm_custom_group' => - array( + 'civicrm_custom_group' => array( 'id', 'name', 'table_name', @@ -393,7 +406,9 @@ LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicr "; // if entity is either individual, organization or household pls get custom groups for 'contact' too. - if ($entityType == "Individual" || $entityType == 'Organization' || $entityType == 'Household') { + if ($entityType == "Individual" || $entityType == 'Organization' || + $entityType == 'Household' + ) { $in = "'$entityType', 'Contact'"; } elseif (strpos($entityType, "'") !== FALSE) { @@ -414,7 +429,9 @@ LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicr $subTypeParts = explode(',', $subType); $subTypeClauses = array(); foreach ($subTypeParts as $subTypePart) { - $subTypePart = CRM_Core_DAO::VALUE_SEPARATOR . trim($subTypePart, CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR; + $subTypePart = CRM_Core_DAO::VALUE_SEPARATOR . + trim($subTypePart, CRM_Core_DAO::VALUE_SEPARATOR) . + CRM_Core_DAO::VALUE_SEPARATOR; $subTypeClauses[] = "civicrm_custom_group.extends_entity_column_value LIKE '%$subTypePart%'"; } @@ -422,11 +439,14 @@ LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicr $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')'; } else { - $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . " OR civicrm_custom_group.extends_entity_column_value IS NULL )"; + $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . + " OR civicrm_custom_group.extends_entity_column_value IS NULL )"; } } else { - $subType = CRM_Core_DAO::VALUE_SEPARATOR . trim($subType, CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR; + $subType = CRM_Core_DAO::VALUE_SEPARATOR . + trim($subType, CRM_Core_DAO::VALUE_SEPARATOR) . + CRM_Core_DAO::VALUE_SEPARATOR; if ($onlySubType) { $subTypeClause = "( civicrm_custom_group.extends_entity_column_value LIKE '%$subType%' )"; @@ -468,9 +488,10 @@ WHERE civicrm_custom_group.is_active = 1 } // ensure that the user has access to these custom groups - $strWhere .= " AND " . CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, - 'civicrm_custom_group.' - ); + $strWhere .= " AND " . + CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, + 'civicrm_custom_group.' + ); $orderBy = " ORDER BY civicrm_custom_group.weight, @@ -484,14 +505,16 @@ ORDER BY civicrm_custom_group.weight, // lets see if we can retrieve the groupTree from cache $cacheString = $queryString; - if ( $groupID > 0 ) { + if ($groupID > 0) { $cacheString .= "_{$groupID}"; - } else { + } + else { $cacheString .= "_Inline"; } $cacheKey = "CRM_Core_DAO_CustomGroup_Query " . md5($cacheString); - $multipleFieldGroupCacheKey = "CRM_Core_DAO_CustomGroup_QueryMultipleFields " . md5($cacheString); + $multipleFieldGroupCacheKey = + "CRM_Core_DAO_CustomGroup_QueryMultipleFields " . md5($cacheString); $cache = CRM_Utils_Cache::singleton(); $tablesWithEntityData = array(); if ($fromCache) { @@ -500,7 +523,7 @@ ORDER BY civicrm_custom_group.weight, } if (empty($groupTree)) { - $groupTree = $multipleFieldGroups =array(); + $groupTree = $multipleFieldGroups = array(); $crmDAO = CRM_Core_DAO::executeQuery($queryString, $params); $customValueTables = array(); @@ -509,7 +532,7 @@ ORDER BY civicrm_custom_group.weight, // get the id's $groupID = $crmDAO->civicrm_custom_group_id; $fieldId = $crmDAO->civicrm_custom_field_id; - if($crmDAO->civicrm_custom_group_is_multiple){ + if ($crmDAO->civicrm_custom_group_is_multiple) { $multipleFieldGroups[$groupID] = $crmDAO->civicrm_custom_group_table_name; } // create an array for groups if it does not exist @@ -571,24 +594,30 @@ ORDER BY civicrm_custom_group.weight, // since we need to know the table and field names // add info to groupTree - if (isset($groupTree['info']) && !empty($groupTree['info']) && !empty($groupTree['info']['tables'])) { + if (isset($groupTree['info']) && !empty($groupTree['info']) && + !empty($groupTree['info']['tables']) + ) { $select = $from = $where = array(); $groupTree['info']['where'] = NULL; foreach ($groupTree['info']['tables'] as $table => $fields) { - $groupTree['info']['from'][] = $table; - $select = array("{$table}.id as {$table}_id", - "{$table}.entity_id as {$table}_entity_id"); + $groupTree['info']['from'][] = $table; + $select = array( + "{$table}.id as {$table}_id", + "{$table}.entity_id as {$table}_entity_id" + ); foreach ($fields as $column => $dontCare) { $select[] = "{$table}.{$column} as {$table}_{$column}"; } $groupTree['info']['select'] = array_merge($groupTree['info']['select'], $select); if ($entityID) { $groupTree['info']['where'][] = "{$table}.entity_id = $entityID"; - if(in_array($table, $multipleFieldGroups) && self::customGroupDataExistsForEntity($entityID, $table)){ + if (in_array($table, $multipleFieldGroups) && + self::customGroupDataExistsForEntity($entityID, $table) + ) { $entityMultipleSelectClauses[$table] = $select; } - else{ + else { $singleFieldTables[] = $table; $entitySingleSelectClauses = array_merge($entitySingleSelectClauses, $select); } @@ -599,11 +628,11 @@ ORDER BY civicrm_custom_group.weight, self::buildEntityTreeSingleFields($groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTables); } $multipleFieldTablesWithEntityData = array_keys($entityMultipleSelectClauses); - if(!empty($multipleFieldTablesWithEntityData)){ + if (!empty($multipleFieldTablesWithEntityData)) { self::buildEntityTreeMultipleFields($groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData); } - } + } return $groupTree; } @@ -618,7 +647,7 @@ ORDER BY civicrm_custom_group.weight, * * @return boolean does this entity have data in this custom table */ - static public function customGroupDataExistsForEntity($entityID, $table, $getCount = FALSE){ + static public function customGroupDataExistsForEntity($entityID, $table, $getCount = FALSE) { $query = " SELECT count(id) FROM $table @@ -631,19 +660,19 @@ ORDER BY civicrm_custom_group.weight, return $recordExists ? TRUE : FALSE; } -/** - * Build the group tree for Custom fields which are not 'is_multiple' - * - * The combination of all these fields in one query with a 'using' join was not working for - * multiple fields. These now have a new behaviour (one at a time) but the single fields still use this - * mechanism as it seemed to be acceptable in this context - * - * @param array $groupTree (reference) group tree array which is being built - * @param integer $entityID id of entity for whom the tree is being build up. - * @param array $entitySingleSelectClauses array of select clauses relevant to the entity - * @param array $singleFieldTablesWithEntityData array of tables in which this entity has data - */ - static public function buildEntityTreeSingleFields(&$groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTablesWithEntityData){ + /** + * Build the group tree for Custom fields which are not 'is_multiple' + * + * The combination of all these fields in one query with a 'using' join was not working for + * multiple fields. These now have a new behaviour (one at a time) but the single fields still use this + * mechanism as it seemed to be acceptable in this context + * + * @param array $groupTree (reference) group tree array which is being built + * @param integer $entityID id of entity for whom the tree is being build up. + * @param array $entitySingleSelectClauses array of select clauses relevant to the entity + * @param array $singleFieldTablesWithEntityData array of tables in which this entity has data + */ + static public function buildEntityTreeSingleFields(&$groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTablesWithEntityData) { $select = implode(', ', $entitySingleSelectClauses); $fromSQL = " (SELECT $entityID as entity_id ) as first "; foreach ($singleFieldTablesWithEntityData as $table) { @@ -659,16 +688,16 @@ ORDER BY civicrm_custom_group.weight, } /** - * Build the group tree for Custom fields which are 'is_multiple' - * - * This is done one table at a time to avoid Cross-Joins resulting in too many rows being returned - * - * @param array $groupTree (reference) group tree array which is being built - * @param integer $entityID id of entity for whom the tree is being build up. - * @param array $entityMultipleSelectClauses array of select clauses relevant to the entity - * @param array $multipleFieldTablesWithEntityData array of tables in which this entity has data - */ - static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData){ + * Build the group tree for Custom fields which are 'is_multiple' + * + * This is done one table at a time to avoid Cross-Joins resulting in too many rows being returned + * + * @param array $groupTree (reference) group tree array which is being built + * @param integer $entityID id of entity for whom the tree is being build up. + * @param array $entityMultipleSelectClauses array of select clauses relevant to the entity + * @param array $multipleFieldTablesWithEntityData array of tables in which this entity has data + */ + static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData) { foreach ($entityMultipleSelectClauses as $table => $selectClauses) { $select = implode(',', $selectClauses); $query = " @@ -691,7 +720,7 @@ ORDER BY civicrm_custom_group.weight, * @param array $includedTables tables to include - required because the function (for historical reasons) * iterates through the group tree */ - static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables){ + static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables) { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { foreach ($groupTree as $groupID => $group) { @@ -702,7 +731,7 @@ ORDER BY civicrm_custom_group.weight, //working from the groupTree instead of the table list means we have to iterate & exclude. // this could possibly be re-written as other parts of the function have been refactored // for now we just check if the given table is to be included in this function - if( !in_array($table, $includedTables)){ + if (!in_array($table, $includedTables)) { continue; } foreach ($group['fields'] as $fieldID => $dontCare) { @@ -721,15 +750,15 @@ ORDER BY civicrm_custom_group.weight, * @param unknown_type $groupID custom group ID * @param unknown_type $fieldID custom field ID */ - static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID){ - $column = $groupTree[$groupID]['fields'][$fieldID]['column_name']; - $idName = "{$table}_id"; + static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID) { + $column = $groupTree[$groupID]['fields'][$fieldID]['column_name']; + $idName = "{$table}_id"; $fieldName = "{$table}_{$column}"; $dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type']; if ($dataType == 'File') { if (isset($dao->$fieldName)) { - $config = CRM_Core_Config::singleton(); - $fileDAO = new CRM_Core_DAO_File(); + $config = CRM_Core_Config::singleton(); + $fileDAO = new CRM_Core_DAO_File(); $fileDAO->id = $dao->$fieldName; if ($fileDAO->find(TRUE)) { @@ -741,13 +770,12 @@ ORDER BY civicrm_custom_group.weight, $customValue['displayURL'] = NULL; $deleteExtra = ts('Are you sure you want to delete attached file.'); $deleteURL = array( - CRM_Core_Action::DELETE => - array( + CRM_Core_Action::DELETE => array( 'name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', - 'extra' => - 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"', + 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . + '\' ) ) this.href+=\'&confirmed=1\'; else return false;"', ), ); $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, @@ -777,7 +805,9 @@ ORDER BY civicrm_custom_group.weight, 'entity_id', 'file_id' ); - $customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) . $fileDAO->uri; + $customValue['imageURL'] = + str_replace('persist/contribute', 'custom', $config->imageUploadURL) . + $fileDAO->uri; list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, NULL, NULL ); @@ -856,8 +886,7 @@ ORDER BY civicrm_custom_group.weight, // using tableData to build the queryString $tableData = array( - 'civicrm_custom_field' => - array( + 'civicrm_custom_field' => array( 'id', 'label', 'data_type', @@ -881,8 +910,7 @@ ORDER BY civicrm_custom_group.weight, 'option_group_id', 'in_selector', ), - 'civicrm_custom_group' => - array( + 'civicrm_custom_group' => array( 'id', 'name', 'title', @@ -941,9 +969,10 @@ ORDER BY civicrm_custom_group.weight, } // ensure that the user has access to these custom groups - $where .= " AND " . CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, - 'civicrm_custom_group.' - ); + $where .= " AND " . + CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, + 'civicrm_custom_group.' + ); $orderBy = " ORDER BY civicrm_custom_group.weight, civicrm_custom_field.weight"; @@ -1021,15 +1050,15 @@ ORDER BY civicrm_custom_group.weight, // process each group with menu tab while ($customGroupDAO->fetch()) { - $group = array(); - $group['id'] = $customGroupDAO->id; - $group['path'] = $path; - $group['title'] = "$customGroupDAO->title"; - $group['query'] = "reset=1&gid={$customGroupDAO->id}&cid={$cidToken}"; - $group['extra'] = array('gid' => $customGroupDAO->id); + $group = array(); + $group['id'] = $customGroupDAO->id; + $group['path'] = $path; + $group['title'] = "$customGroupDAO->title"; + $group['query'] = "reset=1&gid={$customGroupDAO->id}&cid={$cidToken}"; + $group['extra'] = array('gid' => $customGroupDAO->id); $group['table_name'] = $customGroupDAO->table_name; $group['is_multiple'] = $customGroupDAO->is_multiple; - $groups[] = $group; + $groups[] = $group; } return $groups; @@ -1040,7 +1069,7 @@ ORDER BY civicrm_custom_group.weight, * currently if entity type is 'Contact', 'Individual', 'Household', 'Organization' * tableName is 'civicrm_contact' * - * @param string $entityType what entity are we extending here ? + * @param string $entityType what entity are we extending here ? * * @return string $tableName * @@ -1103,6 +1132,7 @@ ORDER BY civicrm_custom_group.weight, * those WILL be included. * * @param $entityType string + * * @return CRM_Core_DAO_CustomGroup */ static function getAllCustomGroupsByBaseEntity($entityType) { @@ -1167,11 +1197,13 @@ ORDER BY civicrm_custom_group.weight, if (!empty($csType)) { $subtypeClause = array(); foreach ($csType as $subtype) { - $subtype = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR; + $subtype = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . + CRM_Core_DAO::VALUE_SEPARATOR; $subtypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%'"; } $subtypeClause[] = "extends_entity_column_value IS NULL"; - $customGroupDAO->whereAdd("( " . implode(' OR ', $subtypeClause) . " )"); + $customGroupDAO->whereAdd("( " . implode(' OR ', $subtypeClause) . + " )"); } else { $customGroupDAO->whereAdd("extends_entity_column_value IS NULL"); @@ -1347,7 +1379,7 @@ ORDER BY civicrm_custom_group.weight, default: if ($field['data_type'] == "Float") { - $defaults[$elementName] = (float)$value; + $defaults[$elementName] = (float) $value; } elseif ($field['data_type'] == 'Money' && $field['html_type'] == 'Text' @@ -1378,8 +1410,10 @@ ORDER BY civicrm_custom_group.weight, $fieldId = $field['id']; //added Multi-Select option in the below if-statement - if ($field['html_type'] == 'CheckBox' || $field['html_type'] == 'Radio' || - $field['html_type'] == 'AdvMulti-Select' || $field['html_type'] == 'Multi-Select' + if ($field['html_type'] == 'CheckBox' || + $field['html_type'] == 'Radio' || + $field['html_type'] == 'AdvMulti-Select' || + $field['html_type'] == 'Multi-Select' ) { $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = 'NULL'; } @@ -1406,7 +1440,10 @@ ORDER BY civicrm_custom_group.weight, case 'CheckBox': if (!empty($v)) { $customValue = array_keys($v); - $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue) . CRM_Core_DAO::VALUE_SEPARATOR; + $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = + CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue) . + CRM_Core_DAO::VALUE_SEPARATOR; } else { $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = NULL; @@ -1419,7 +1456,10 @@ ORDER BY civicrm_custom_group.weight, //added for Multi-Select case 'Multi-Select': if (!empty($v)) { - $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $v) . CRM_Core_DAO::VALUE_SEPARATOR; + $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = + CRM_Core_DAO::VALUE_SEPARATOR . + implode(CRM_Core_DAO::VALUE_SEPARATOR, $v) . + CRM_Core_DAO::VALUE_SEPARATOR; } else { $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = NULL; @@ -1482,7 +1522,7 @@ ORDER BY civicrm_custom_group.weight, /** * Generic function to build all the form elements for a specific group tree * - * @param CRM_Core_Form $form the form object + * @param CRM_Core_Form $form the form object * @param array $groupTree the group tree object * @param boolean $inactiveNeeded return inactive custom groups * @param string $prefix prefix for custom grouptree assigned to template @@ -1491,7 +1531,7 @@ ORDER BY civicrm_custom_group.weight, * @access public * @static */ - static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '' ) { + static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FALSE, $prefix = '') { $form->assign_by_ref("{$prefix}groupTree", $groupTree); // this is fix for date field @@ -1520,7 +1560,7 @@ ORDER BY civicrm_custom_group.weight, * and store it in session * * @param CRM_Core_Form $form the form object - * @param string $type the type of custom group we are using + * @param string $type the type of custom group we are using * * @return array * @access public @@ -1531,9 +1571,15 @@ ORDER BY civicrm_custom_group.weight, return array(); } - $groupTree = CRM_Core_BAO_CustomGroup::getTree($type, $form); + $groupTree = CRM_Core_BAO_CustomGroup::getTree($type, $form); $customValue = array(); - $htmlType = array('CheckBox', 'Multi-Select', 'AdvMulti-Select', 'Select', 'Radio'); + $htmlType = array( + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + 'Select', + 'Radio' + ); foreach ($groupTree as $group) { if (!isset($group['fields'])) { @@ -1554,13 +1600,15 @@ ORDER BY civicrm_custom_group.weight, $field['html_type'] == 'AdvMulti-Select' || $field['html_type'] == 'Multi-Select' ) { - $value = str_replace("|", ",", $value); - $mulValues = explode(',', $value); + $value = str_replace("|", ",", $value); + $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($key, TRUE); - $val = array(); + $val = array(); foreach ($mulValues as $v1) { foreach ($customOption as $coID => $coValue) { - if (strtolower(trim($coValue['label'])) == strtolower(trim($v1))) { + if (strtolower(trim($coValue['label'])) == + strtolower(trim($v1)) + ) { $val[$coValue['value']] = 1; } } @@ -1580,7 +1628,9 @@ ORDER BY civicrm_custom_group.weight, ) { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($key, TRUE); foreach ($customOption as $customID => $coValue) { - if (strtolower(trim($coValue['label'])) == strtolower(trim($value))) { + if (strtolower(trim($coValue['label'])) == + strtolower(trim($value)) + ) { $value = $coValue['value']; $valid = TRUE; } @@ -1590,9 +1640,11 @@ ORDER BY civicrm_custom_group.weight, if (!empty($value)) { $time = NULL; if (!empty($field['time_format'])) { - $time = CRM_Utils_Request::retrieve($fieldName . '_time', 'String', $form, FALSE, NULL, 'GET'); + $time = CRM_Utils_Request::retrieve($fieldName . + '_time', 'String', $form, FALSE, NULL, 'GET'); } - list($value, $time) = CRM_Utils_Date::setDateDefaults($value . ' ' . $time); + list($value, $time) = CRM_Utils_Date::setDateDefaults($value . + ' ' . $time); if (!empty($field['time_format'])) { $customValue[$fieldName . '_time'] = $time; } @@ -1614,8 +1666,8 @@ ORDER BY civicrm_custom_group.weight, * Check the type of custom field type (eg: Used for Individual, Contribution, etc) * this function is used to get the custom fields of a type (eg: Used for Individual, Contribution, etc ) * - * @param int $customFieldId custom field id - * @param array $removeCustomFieldTypes remove custom fields of a type eg: array("Individual") ; + * @param int $customFieldId custom field id + * @param array $removeCustomFieldTypes remove custom fields of a type eg: array("Individual") ; * * * @return boolean false if it matches else true @@ -1626,7 +1678,8 @@ ORDER BY civicrm_custom_group.weight, $query = "SELECT cg.extends as extends FROM civicrm_custom_group as cg, civicrm_custom_field as cf WHERE cg.id = cf.custom_group_id - AND cf.id =" . CRM_Utils_Type::escape($customFieldId, 'Integer'); + AND cf.id =" . + CRM_Utils_Type::escape($customFieldId, 'Integer'); $extends = CRM_Core_DAO::singleValueQuery($query); @@ -1723,8 +1776,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, /** * Function returns formatted groupTree, sothat form can be easily build in template * - * @param array $groupTree associated array - * @param int $groupCount group count by default 1, but can varry for multiple value custom data + * @param array $groupTree associated array + * @param int $groupCount group count by default 1, but can varry for multiple value custom data * @param object form object * * @return array $formattedGroupTree @@ -1757,7 +1810,9 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, // add field information foreach ($value['fields'] as $k => $properties) { $properties['element_name'] = "custom_{$k}_-{$groupCount}"; - if (isset($properties['customValue']) && !CRM_Utils_System::isNull($properties['customValue'])) { + if (isset($properties['customValue']) && + !CRM_Utils_System::isNull($properties['customValue']) + ) { if (isset($properties['customValue'][$groupCount])) { $properties['element_name'] = "custom_{$k}_{$properties['customValue'][$groupCount]['id']}"; $formattedGroupTree[$key]['table_id'] = $properties['customValue'][$groupCount]['id']; @@ -1820,7 +1875,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $details[$groupID][$values['id']]['help_post'] = CRM_Utils_Array::value('help_post', $group); $details[$groupID][$values['id']]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); $details[$groupID][$values['id']]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); - $details[$groupID][$values['id']]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties), + $details[$groupID][$values['id']]['fields'][$k] = array( + 'field_title' => CRM_Utils_Array::value('label', $properties), 'field_type' => CRM_Utils_Array::value('html_type', $properties ), @@ -1835,8 +1891,11 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, ), ); // also return contact reference contact id if user has view all or edit all contacts perm - if ((CRM_Core_Permission::check('view all contacts') || CRM_Core_Permission::check('edit all contacts')) - && $details[$groupID][$values['id']]['fields'][$k]['field_data_type'] == 'ContactReference' + if ((CRM_Core_Permission::check('view all contacts') || + CRM_Core_Permission::check('edit all contacts')) + && + $details[$groupID][$values['id']]['fields'][$k]['field_data_type'] == + 'ContactReference' ) { $details[$groupID][$values['id']]['fields'][$k]['contact_ref_id'] = CRM_Utils_Array::value('data', $values); } @@ -1857,12 +1916,12 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, if ($returnCount) { //return a single value count if group id is passed to function //else return a groupId and count mapped array - if (!empty($gID)){ + if (!empty($gID)) { return count($details[$gID]); } else { $countValue = array(); - foreach( $details as $key => $value ) { + foreach ($details as $key => $value) { $countValue[$key] = count($details[$key]); } return $countValue; @@ -1891,11 +1950,11 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, return; } - $htmlType = CRM_Utils_Array::value('html_type', $field); - $dataType = CRM_Utils_Array::value('data_type', $field); + $htmlType = CRM_Utils_Array::value('html_type', $field); + $dataType = CRM_Utils_Array::value('data_type', $field); $option_group_id = CRM_Utils_Array::value('option_group_id', $field); - $timeFormat = CRM_Utils_Array::value('time_format', $field); - $optionPerLine = CRM_Utils_Array::value('options_per_line', $field); + $timeFormat = CRM_Utils_Array::value('time_format', $field); + $optionPerLine = CRM_Utils_Array::value('options_per_line', $field); $freezeString = ""; $freezeStringChecked = ""; @@ -1924,7 +1983,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, 'dd-mm' => "%E%f %B $customTimeFormat", 'yy' => "%Y $customTimeFormat", 'M yy' => "%b %Y $customTimeFormat", - 'yy-mm' => "%Y-%m $customTimeFormat" + 'yy-mm' => "%Y-%m $customTimeFormat" ); if ($format = CRM_Utils_Array::value('date_format', $field)) { @@ -1967,7 +2026,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, case 'Float': if ($htmlType == 'Text') { - $retValue = (float)$value; + $retValue = (float) $value; break; } case 'Money': @@ -1981,8 +2040,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $retValue = $value; break; } - // note that if its not text / textarea, the code falls thru and executes - // the below case also + // note that if its not text / textarea, the code falls thru and executes + // the below case also case 'StateProvince': case 'Country': $options = array(); @@ -1997,119 +2056,121 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, case 'Select Country': $customData = $value; if (!is_array($value)) { - $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - } - $query = " + $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + } + $query = " SELECT id as value, name as label FROM civicrm_country"; - $coDAO = CRM_Core_DAO::executeQuery($query); - break; - - case 'Select State/Province': - case 'Multi-Select State/Province': - $customData = $value; - if (!is_array($value)) { - $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - } + $coDAO = CRM_Core_DAO::executeQuery($query); + break; - $query = " + case 'Select State/Province': + case 'Multi-Select State/Province': + $customData = $value; + if (!is_array($value)) { + $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + } + + $query = " SELECT id as value, name as label FROM civicrm_state_province"; - $coDAO = CRM_Core_DAO::executeQuery($query); - break; + $coDAO = CRM_Core_DAO::executeQuery($query); + break; - case 'Select': - $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - if ($option_group_id) { - $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id); - } - break; - - case 'CheckBox': - case 'AdvMulti-Select': - case 'Multi-Select': - $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - default: - if ($option_group_id) { - $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id); - } - } + case 'Select': + $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + if ($option_group_id) { + $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id); + } + break; - if (is_object($coDAO)) { - while ($coDAO->fetch()) { - if ($dataType == 'Country') { - // NB: using ts() on a variable here is OK, since the value is pre-determined, not variable - // and already extracted to .pot files. - $options[$coDAO->value] = ts($coDAO->label, array('context' => 'country')); - } - elseif ($dataType == 'StateProvince') { - $options[$coDAO->value] = ts($coDAO->label, array('context' => 'province')); - } - else { - $options[$coDAO->value] = $coDAO->label; - } - } - } + case 'CheckBox': + case 'AdvMulti-Select': + case 'Multi-Select': + $customData = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + default: + if ($option_group_id) { + $options = CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($option_group_id); + } + } - CRM_Utils_Hook::customFieldOptions($field['id'], $options, FALSE); + if (is_object($coDAO)) { + while ($coDAO->fetch()) { + if ($dataType == 'Country') { + // NB: using ts() on a variable here is OK, since the value is pre-determined, not variable + // and already extracted to .pot files. + $options[$coDAO->value] = ts($coDAO->label, array('context' => 'country')); + } + elseif ($dataType == 'StateProvince') { + $options[$coDAO->value] = ts($coDAO->label, array('context' => 'province')); + } + else { + $options[$coDAO->value] = $coDAO->label; + } + } + } - $retValue = NULL; - foreach ($options as $optionValue => $optionLabel) { - if ($dataType == 'Money') { - foreach ($customData as $k => $v) { - $customData[] = CRM_Utils_Money::format($v, NULL, '%a'); - } - } + CRM_Utils_Hook::customFieldOptions($field['id'], $options, FALSE); - //to show only values that are checked - if (in_array((string) $optionValue, $customData)) { - $checked = in_array($optionValue, $customData) ? $freezeStringChecked : $freezeString; - if (!$optionPerLine || $dncOptionPerLine) { - if ($retValue) { + $retValue = NULL; + foreach ($options as $optionValue => $optionLabel) { + if ($dataType == 'Money') { + foreach ($customData as $k => $v) { + $customData[] = CRM_Utils_Money::format($v, NULL, '%a'); + } + } + + //to show only values that are checked + if (in_array((string) $optionValue, $customData)) { + $checked = in_array($optionValue, $customData) ? $freezeStringChecked : $freezeString; + if (!$optionPerLine || $dncOptionPerLine) { + if ($retValue) { $retValue .= ", "; - } - $retValue .= $checked . $optionLabel; - } - else { - $retValue[] = $checked . $optionLabel; - } - } - } - break; + } + $retValue .= $checked . $optionLabel; } + else { + $retValue[] = $checked . $optionLabel; + } + } + } + break; + } - //special case for option per line formatting - if ($optionPerLine > 1 && is_array($retValue)) { - $rowCounter = 0; - $fieldCounter = 0; - $displayValues = array(); + //special case for option per line formatting + if ($optionPerLine > 1 && is_array($retValue)) { + $rowCounter = 0; + $fieldCounter = 0; + $displayValues = array(); $displayString = ''; - foreach ($retValue as $val) { - if ($displayString) { + foreach ($retValue as $val) { + if ($displayString) { $displayString .= ", "; - } + } - $displayString .= $val; - $rowCounter++; - $fieldCounter++; + $displayString .= $val; + $rowCounter++; + $fieldCounter++; - if (($rowCounter == $optionPerLine) || ($fieldCounter == count($retValue))) { - $displayValues[] = $displayString; - $displayString = ''; - $rowCounter = 0; - } - } - $retValue = $displayValues; - } + if (($rowCounter == $optionPerLine) || + ($fieldCounter == count($retValue)) + ) { + $displayValues[] = $displayString; + $displayString = ''; + $rowCounter = 0; + } + } + $retValue = $displayValues; + } - $retValue = isset($retValue) ? $retValue : NULL; - return $retValue; - } + $retValue = isset($retValue) ? $retValue : NULL; + return $retValue; + } /** * Get the custom group titles by custom field ids. * - * @param array $fieldIds - array of custom field ids. + * @param array $fieldIds - array of custom field ids. * * @return array $groupLabels - array consisting of groups and fields labels with ids. * @access public @@ -2136,7 +2197,7 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT 'fieldLabel' => $dao->fieldLabel, 'groupID' => $dao->groupID, 'groupTitle' => $dao->groupTitle, - ); + ); } return $groupLabels; @@ -2155,7 +2216,7 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT /** * Check whether custom group is empty or not. * - * @param int $gID - custom group id. + * @param int $gID - custom group id. * * @return boolean true if empty otherwise false. * @access public @@ -2166,9 +2227,9 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT } $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', - $gID, - 'table_name' - ); + $gID, + 'table_name' + ); $query = "SELECT count(id) FROM {$tableName} WHERE id IS NOT NULL LIMIT 1"; $value = CRM_Core_DAO::singleValueQuery($query); @@ -2188,7 +2249,7 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT * @return array of types. * @access public */ - static function getExtendedObjectTypes(&$types = array( )) { + static function getExtendedObjectTypes(&$types = array()) { static $flag = FALSE, $objTypes = array(); if (!$flag) { @@ -2209,7 +2270,8 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT } list($className) = explode('::', $callback); - require_once (str_replace('_',DIRECTORY_SEPARATOR, $className) . '.php'); + require_once(str_replace('_', DIRECTORY_SEPARATOR, $className) . + '.php'); $objTypes[$ovValues['value']] = call_user_func_array($callback, $args); } @@ -2233,10 +2295,12 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT $isMultiple = ($isMultiple) ? TRUE : FALSE; $hasReachedMax = FALSE; if ($isMultiple && - ($maxMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'max_multiple'))) { + ($maxMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'max_multiple')) + ) { if (!$maxMultiple) { $hasReachedMax = FALSE; - } else { + } + else { $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name'); //count the number of entries for a entity $sql = "SELECT COUNT(id) FROM {$tableName} WHERE entity_id = %1"; @@ -2257,12 +2321,12 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT static function getMultipleFieldGroup() { $multipleGroup = array(); $dao = new CRM_Core_DAO_CustomGroup(); - $dao->is_multiple = 1 ; + $dao->is_multiple = 1; $dao->find(); - while($dao->fetch()) { + while ($dao->fetch()) { $multipleGroup[$dao->id] = $dao->title; } return $multipleGroup; } - } +} diff --git a/CRM/Custom/Import/Form/DataSource.php b/CRM/Custom/Import/Form/DataSource.php index 07b4c0a9b4..b03f7c3ab5 100644 --- a/CRM/Custom/Import/Form/DataSource.php +++ b/CRM/Custom/Import/Form/DataSource.php @@ -139,8 +139,7 @@ class CRM_Custom_Import_Form_DataSource extends CRM_Core_Form { ); $this->setDefaults(array( - 'contactType' => - CRM_Import_Parser::CONTACT_INDIVIDUAL, + 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, )); //build date formats diff --git a/CRM/Event/Import/Form/DataSource.php b/CRM/Event/Import/Form/DataSource.php index 9e94eafc00..725116a884 100644 --- a/CRM/Event/Import/Form/DataSource.php +++ b/CRM/Event/Import/Form/DataSource.php @@ -130,8 +130,7 @@ class CRM_Event_Import_Form_DataSource extends CRM_Core_Form { $this->addGroup($contactOptions, 'contactType', ts('Contact Type')); $this->setDefaults(array( - 'contactType' => - CRM_Import_Parser::CONTACT_INDIVIDUAL, + 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, ) ); diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index e29071a9e1..6e1c05653c 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -59,33 +59,30 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { $this->_logTables = array( - 'log_civicrm_contact' => - array( + 'log_civicrm_contact' => array( 'fk' => 'id', ), - 'log_civicrm_email' => - array( + 'log_civicrm_email' => array( 'fk' => 'contact_id', 'log_type' => 'Contact', ), - 'log_civicrm_phone' => - array( + 'log_civicrm_phone' => array( 'fk' => 'contact_id', 'log_type' => 'Contact', ), - 'log_civicrm_address' => - array( + 'log_civicrm_address' => array( 'fk' => 'contact_id', 'log_type' => 'Contact', ), - 'log_civicrm_note' => - array( + 'log_civicrm_note' => array( 'fk' => 'entity_id', 'entity_table' => TRUE, - 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject'), + 'bracket_info' => array( + 'table' => 'log_civicrm_note', + 'column' => 'subject' + ), ), - 'log_civicrm_note_comment' => - array( + 'log_civicrm_note_comment' => array( 'fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array( @@ -93,23 +90,31 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'" ), 'entity_table' => TRUE, - 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject'), + 'bracket_info' => array( + 'table' => 'log_civicrm_note', + 'column' => 'subject' + ), ), - 'log_civicrm_group_contact' => - array( + 'log_civicrm_group_contact' => array( 'fk' => 'contact_id', - 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), + 'bracket_info' => array( + 'entity_column' => 'group_id', + 'table' => 'log_civicrm_group', + 'column' => 'title' + ), 'action_column' => 'status', 'log_type' => 'Group', ), - 'log_civicrm_entity_tag' => - array( + 'log_civicrm_entity_tag' => array( 'fk' => 'entity_id', - 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), + 'bracket_info' => array( + 'entity_column' => 'tag_id', + 'table' => 'log_civicrm_tag', + 'column' => 'name' + ), 'entity_table' => TRUE ), - 'log_civicrm_relationship' => - array( + 'log_civicrm_relationship' => array( 'fk' => 'contact_id_a', 'bracket_info' => array( 'entity_column' => 'relationship_type_id', @@ -117,8 +122,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { 'column' => 'label_a_b' ), ), - 'log_civicrm_activity_for_target' => - array( + 'log_civicrm_activity_for_target' => array( 'fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array( @@ -131,8 +135,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { ), 'log_type' => 'Activity', ), - 'log_civicrm_activity_for_assignee' => - array( + 'log_civicrm_activity_for_assignee' => array( 'fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array( @@ -145,8 +148,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { ), 'log_type' => 'Activity', ), - 'log_civicrm_activity_for_source' => - array( + 'log_civicrm_activity_for_source' => array( 'fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array( @@ -159,8 +161,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { ), 'log_type' => 'Activity', ), - 'log_civicrm_case' => - array( + 'log_civicrm_case' => array( 'fk' => 'contact_id', 'joins' => array( 'table' => 'log_civicrm_case_contact', @@ -178,7 +179,10 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { // build _logTables for contact custom tables $customTables = $logging->entityCustomDataLogTables('Contact'); foreach ($customTables as $table) { - $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact'); + $this->_logTables[$table] = array( + 'fk' => 'entity_id', + 'log_type' => 'Contact' + ); } // build _logTables for address custom tables @@ -189,7 +193,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { 'fk' => 'contact_id',// for join of fk_table with contact table 'joins' => array( 'table' => 'log_civicrm_address', // fk_table - 'join' => 'entity_log_civireport.entity_id = fk_table.id' + 'join' => 'entity_log_civireport.entity_id = fk_table.id' ), 'log_type' => 'Contact' ); @@ -211,7 +215,9 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (CRM_Utils_Array::value('required', $field) or CRM_Utils_Array::value($fieldName, $this->_params['fields'])) { + if (CRM_Utils_Array::value('required', $field) or + CRM_Utils_Array::value($fieldName, $this->_params['fields']) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); @@ -382,7 +388,9 @@ SELECT {$this->_logTables[$entity]['bracket_info']['entity_column']} } - if ($entityID && $logDate && array_key_exists('table', $this->_logTables[$entity]['bracket_info'])) { + if ($entityID && $logDate && + array_key_exists('table', $this->_logTables[$entity]['bracket_info']) + ) { $sql = " SELECT {$this->_logTables[$entity]['bracket_info']['column']} FROM `{$this->loggingDB}`.{$this->_logTables[$entity]['bracket_info']['table']} @@ -393,7 +401,9 @@ WHERE log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1"; )); } else { - if (array_key_exists('options', $this->_logTables[$entity]['bracket_info']) && $entityID) { + if (array_key_exists('options', $this->_logTables[$entity]['bracket_info']) && + $entityID + ) { return CRM_Utils_Array::value($entityID, $this->_logTables[$entity]['bracket_info']['options']); } } diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 8e5b5842e1..5ab7cde0c1 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1743,8 +1743,7 @@ ORDER BY civicrm_email.is_bulkmail DESC 'delivered' => CRM_Mailing_Event_BAO_Delivered::getTableName(), 'opened' => CRM_Mailing_Event_BAO_Opened::getTableName(), 'reply' => CRM_Mailing_Event_BAO_Reply::getTableName(), - 'unsubscribe' => - CRM_Mailing_Event_BAO_Unsubscribe::getTableName(), + 'unsubscribe' => CRM_Mailing_Event_BAO_Unsubscribe::getTableName(), 'bounce' => CRM_Mailing_Event_BAO_Bounce::getTableName(), 'forward' => CRM_Mailing_Event_BAO_Forward::getTableName(), 'url' => CRM_Mailing_BAO_TrackableURL::getTableName(), diff --git a/CRM/Mailing/Form/Schedule.php b/CRM/Mailing/Form/Schedule.php index e814fef894..dcef3c9778 100644 --- a/CRM/Mailing/Form/Schedule.php +++ b/CRM/Mailing/Form/Schedule.php @@ -249,8 +249,7 @@ class CRM_Mailing_Form_Schedule extends CRM_Core_Form { $params['start_date_time'] )) < CRM_Utils_Date::format(date('YmdHi00'))) { return array( - 'start_date' => - ts('Start date cannot be earlier than the current time.'), + 'start_date' => ts('Start date cannot be earlier than the current time.'), ); } return TRUE; diff --git a/CRM/Member/Import/Form/DataSource.php b/CRM/Member/Import/Form/DataSource.php index e358626089..ab4ae4941e 100644 --- a/CRM/Member/Import/Form/DataSource.php +++ b/CRM/Member/Import/Form/DataSource.php @@ -86,8 +86,7 @@ class CRM_Member_Import_Form_DataSource extends CRM_Core_Form { ts('Import mode') ); $this->setDefaults(array( - 'onDuplicate' => - CRM_Import_Parser::DUPLICATE_SKIP, + 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, )); //get the saved mapping details @@ -126,8 +125,7 @@ class CRM_Member_Import_Form_DataSource extends CRM_Core_Form { ); $this->setDefaults(array( - 'contactType' => - CRM_Import_Parser::CONTACT_INDIVIDUAL, + 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, )); //build date formats diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 5a672f4f15..ccace10fe6 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -39,11 +39,11 @@ class CRM_Report_Form extends CRM_Core_Form { * Operator types - used for displaying filter elements */ CONST - OP_INT = 1, + OP_INT = 1, OP_STRING = 2, - OP_DATE = 4, + OP_DATE = 4, OP_DATETIME = 5, - OP_FLOAT = 8, + OP_FLOAT = 8, OP_SELECT = 64, OP_MULTISELECT = 65, OP_MULTISELECT_SEPARATOR = 66, @@ -139,7 +139,7 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_customGroupExtendsJoin = array(); protected $_customGroupFilters = TRUE; protected $_customGroupGroupBy = FALSE; - protected $_customGroupJoin = 'LEFT JOIN'; + protected $_customGroupJoin = 'LEFT JOIN'; /** * Build tags filter @@ -168,8 +168,10 @@ class CRM_Report_Form extends CRM_Core_Form { * @var array */ protected $_fourColumnAttribute = array( - '', '', - '', '', + '', + '', + '', + '', ); protected $_force = 1; @@ -272,7 +274,7 @@ class CRM_Report_Form extends CRM_Core_Form { public $_columnHeaders = array(); public $_orderBy = NULL; public $_orderByFields = array(); - public $_orderByArray = array(); + public $_orderByArray = array(); public $_groupBy = NULL; public $_whereClauses = array(); public $_havingClauses = array(); @@ -366,13 +368,13 @@ class CRM_Report_Form extends CRM_Core_Form { CRM_Core_Region::instance('page-header')->add(array( 'markup' => sprintf('', htmlentities(get_class($this))), )); - if(!$this->noController) { + if (!$this->noController) { $this->setID($this->get('instanceId')); if (!$this->_id) { $this->setID(CRM_Report_Utils_Report::getInstanceID()); if (!$this->_id) { - $this->setID( CRM_Report_Utils_Report::getInstanceIDForPath()); + $this->setID(CRM_Report_Utils_Report::getInstanceIDForPath()); } } @@ -442,14 +444,20 @@ class CRM_Report_Form extends CRM_Core_Form { // Do not display Report Settings section if administer Reports permission is absent OR // if report instance is reserved and administer reserved reports absent if (!CRM_Core_Permission::check('administer Reports') || - ($this->_instanceValues['is_reserved'] && !CRM_Core_Permission::check('administer reserved reports'))) { + ($this->_instanceValues['is_reserved'] && + !CRM_Core_Permission::check('administer reserved reports')) + ) { $this->_instanceForm = FALSE; } $this->assign('criteriaForm', FALSE); // Display Report Criteria section if user has access Report Criteria OR administer Reports AND report instance is not reserved - if (CRM_Core_Permission::check('administer Reports') || CRM_Core_Permission::check('access Report Criteria')) { - if (!$this->_instanceValues['is_reserved'] || CRM_Core_Permission::check('administer reserved reports')) { + if (CRM_Core_Permission::check('administer Reports') || + CRM_Core_Permission::check('access Report Criteria') + ) { + if (!$this->_instanceValues['is_reserved'] || + CRM_Core_Permission::check('administer reserved reports') + ) { $this->assign('criteriaForm', TRUE); $this->_criteriaForm = TRUE; } @@ -486,7 +494,8 @@ class CRM_Report_Form extends CRM_Core_Form { foreach ($this->_columns as $tableName => $table) { // set alias if (!isset($table['alias'])) { - $this->_columns[$tableName]['alias'] = substr($tableName, 8) . '_civireport'; + $this->_columns[$tableName]['alias'] = substr($tableName, 8) . + '_civireport'; } else { $this->_columns[$tableName]['alias'] = $table['alias'] . '_civireport'; @@ -498,13 +507,13 @@ class CRM_Report_Form extends CRM_Core_Form { // higher preference to bao object if (array_key_exists('bao', $table)) { $daoOrBaoName = $table['bao']; - $expFields = $daoOrBaoName::exportableFields( ); + $expFields = $daoOrBaoName::exportableFields(); } - elseif (array_key_exists('dao', $table)){ + elseif (array_key_exists('dao', $table)) { $daoOrBaoName = $table['dao']; - $expFields = $daoOrBaoName::export( ); + $expFields = $daoOrBaoName::export(); } - else{ + else { $expFields = array(); } @@ -550,7 +559,7 @@ class CRM_Report_Form extends CRM_Core_Form { // set alias = table-name, unless already set $alias = isset($field['alias']) ? $field['alias'] : (isset($this->_columns[$tableName]['alias']) ? - $this->_columns[$tableName]['alias'] : $tableName + $this->_columns[$tableName]['alias'] : $tableName ); $this->_columns[$tableName][$fieldGrp][$fieldName]['alias'] = $alias; @@ -561,7 +570,9 @@ class CRM_Report_Form extends CRM_Core_Form { // set dbAlias = alias.name, unless already set if (!isset($this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'])) { - $this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'] = $alias . '.' . $this->_columns[$tableName][$fieldGrp][$fieldName]['name']; + $this->_columns[$tableName][$fieldGrp][$fieldName]['dbAlias'] = + $alias . '.' . + $this->_columns[$tableName][$fieldGrp][$fieldName]['name']; } // a few auto fills for filters @@ -583,12 +594,17 @@ class CRM_Report_Form extends CRM_Core_Form { $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT; if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) { $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] = - array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')); + array( + '' => ts('Any'), + '0' => ts('No'), + '1' => ts('Yes') + ); } break; default: if ($daoOrBaoName && - array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])) { + array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName]) + ) { // with multiple options operator-type is generally multi-select $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT; if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) { @@ -680,13 +696,14 @@ class CRM_Report_Form extends CRM_Core_Form { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { if (isset($field['default'])) { - if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - if(is_array($field['default'])){ + if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE + ) { + if (is_array($field['default'])) { $this->_defaults["{$fieldName}_from"] = CRM_Utils_Array::value('from', $field['default']); $this->_defaults["{$fieldName}_to"] = CRM_Utils_Array::value('to', $field['default']); $this->_defaults["{$fieldName}_relative"] = 0; } - else{ + else { $this->_defaults["{$fieldName}_relative"] = $field['default']; } } @@ -696,13 +713,19 @@ class CRM_Report_Form extends CRM_Core_Form { } //assign default value as "in" for multiselect //operator, To freeze the select element - if (CRM_Utils_Array::value('operatorType', $field) == CRM_Report_Form::OP_MULTISELECT) { + if (CRM_Utils_Array::value('operatorType', $field) == + CRM_Report_Form::OP_MULTISELECT + ) { $this->_defaults["{$fieldName}_op"] = 'in'; } - if (CRM_Utils_Array::value('operatorType', $field) == CRM_Report_Form::OP_ENTITYREF) { + if (CRM_Utils_Array::value('operatorType', $field) == + CRM_Report_Form::OP_ENTITYREF + ) { $this->_defaults["{$fieldName}_op"] = 'in'; } - elseif (CRM_Utils_Array::value('operatorType', $field) == CRM_Report_Form::OP_MULTISELECT_SEPARATOR) { + elseif (CRM_Utils_Array::value('operatorType', $field) == + CRM_Report_Form::OP_MULTISELECT_SEPARATOR + ) { $this->_defaults["{$fieldName}_op"] = 'mhas'; } elseif ($op = CRM_Utils_Array::value('default_op', $field)) { @@ -720,7 +743,9 @@ class CRM_Report_Form extends CRM_Core_Form { } foreach ($table['order_bys'] as $fieldName => $field) { if (!empty($field['default']) || !empty($field['default_order']) || - CRM_Utils_Array::value('default_is_section', $field) || !empty($field['default_weight'])) { + CRM_Utils_Array::value('default_is_section', $field) || + !empty($field['default_weight']) + ) { $order_by = array( 'column' => $fieldName, 'order' => CRM_Utils_Array::value('default_order', $field, 'ASC'), @@ -789,6 +814,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Setter for $_params + * * @param array $params */ function setParams($params) { @@ -806,14 +832,16 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Setter for $_force - * @param bool $isForce -*/ + * + * @param $isForce + */ function setForce($isForce) { $this->_force = $isForce; } /** * Setter for $_limitValue + * * @param number $_limitValue */ function setLimitValue($_limitValue) { @@ -822,6 +850,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Setter for $_offsetValue + * * @param number $_offsetValue */ function setOffsetValue($_offsetValue) { @@ -844,11 +873,12 @@ class CRM_Report_Form extends CRM_Core_Form { foreach ($table['fields'] as $fieldName => $field) { $groupTitle = ''; if (empty($field['no_display'])) { - foreach ( array('table', 'field') as $var) { + foreach (array('table', 'field') as $var) { if (!empty(${$var}['grouping'])) { if (!is_array(${$var}['grouping'])) { $tableName = ${$var}['grouping']; - } else { + } + else { $tableName = array_keys(${$var}['grouping']); $tableName = $tableName[0]; $groupTitle = array_values(${$var}['grouping']); @@ -894,7 +924,9 @@ class CRM_Report_Form extends CRM_Core_Form { switch (CRM_Utils_Array::value('operatorType', $field)) { case CRM_Report_Form::OP_MONTH: - if (!array_key_exists('options', $field) || !is_array($field['options']) || empty($field['options'])) { + if (!array_key_exists('options', $field) || + !is_array($field['options']) || empty($field['options']) + ) { // If there's no option list for this filter, define one. $field['options'] = array( 1 => ts('January'), @@ -917,13 +949,21 @@ class CRM_Report_Form extends CRM_Core_Form { case CRM_Report_Form::OP_MULTISELECT: case CRM_Report_Form::OP_MULTISELECT_SEPARATOR: // assume a multi-select field - if (!empty($field['options']) || $fieldName == 'state_province_id' || $fieldName == 'county_id') { + if (!empty($field['options']) || + $fieldName == 'state_province_id' || $fieldName == 'county_id' + ) { $element = $this->addElement('select', "{$fieldName}_op", ts('Operator:'), $operations); if (count($operations) <= 1) { $element->freeze(); } - if ($fieldName == 'state_province_id' || $fieldName == 'county_id') { - $this->addChainSelect($fieldName . '_value', array('multiple' => TRUE, 'label' => NULL, 'class' => 'huge')); + if ($fieldName == 'state_province_id' || + $fieldName == 'county_id' + ) { + $this->addChainSelect($fieldName . '_value', array( + 'multiple' => TRUE, + 'label' => NULL, + 'class' => 'huge' + )); } else { $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], array( @@ -939,8 +979,9 @@ class CRM_Report_Form extends CRM_Core_Form { case CRM_Report_Form::OP_SELECT: // assume a select field $this->addElement('select', "{$fieldName}_op", ts('Operator:'), $operations); - if (!empty($field['options'])) + if (!empty($field['options'])) { $this->addElement('select', "{$fieldName}_value", NULL, $field['options']); + } break; case CRM_Report_Form::OP_ENTITYREF: @@ -951,13 +992,13 @@ class CRM_Report_Form extends CRM_Core_Form { case CRM_Report_Form::OP_DATE: // build datetime fields - CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from','_to', 'From:', FALSE, $operations); + CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from', '_to', 'From:', FALSE, $operations); $count++; break; case CRM_Report_Form::OP_DATETIME: // build datetime fields - CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from', '_to', 'From:', FALSE, $operations, 'searchDate', true); + CRM_Core_Form_Date::buildDateRange($this, $fieldName, $count, '_from', '_to', 'From:', FALSE, $operations, 'searchDate', TRUE); $count++; break; @@ -1056,7 +1097,9 @@ class CRM_Report_Form extends CRM_Core_Form { */ - if ($this->_autoIncludeIndexedFieldsAsOrderBys && array_key_exists('extends', $table) && !empty($table['extends'])) { + if ($this->_autoIncludeIndexedFieldsAsOrderBys && + array_key_exists('extends', $table) && !empty($table['extends']) + ) { foreach ($table['fields'] as $fieldName => $field) { if (empty($field['no_display'])) { $options[$fieldName] = $field['title']; @@ -1071,10 +1114,14 @@ class CRM_Report_Form extends CRM_Core_Form { if (!empty($options)) { $options = array( - '-' => ' - none - ') + $options; + '-' => ' - none - ' + ) + $options; for ($i = 1; $i <= 5; $i++) { $this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options); - $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array('ASC' => 'Ascending', 'DESC' => 'Descending')); + $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array( + 'ASC' => 'Ascending', + 'DESC' => 'Descending' + )); $this->addElement('checkbox', "order_bys[{$i}][section]", ts('Order by Section'), FALSE, array('id' => "order_by_section_$i")); $this->addElement('checkbox', "order_bys[{$i}][pageBreak]", ts('Page Break'), FALSE, array('id' => "order_by_pagebreak_$i")); } @@ -1091,7 +1138,8 @@ class CRM_Report_Form extends CRM_Core_Form { $this->addElement('submit', $this->_pdfButtonName, ts('PDF')); if ($this->_id) { - $this->addElement('submit', $this->_createNewButtonName, ts('Save a Copy') . '...'); + $this->addElement('submit', $this->_createNewButtonName, + ts('Save a Copy') . '...'); } if ($this->_instanceForm) { $this->assign('instanceForm', TRUE); @@ -1109,9 +1157,12 @@ class CRM_Report_Form extends CRM_Core_Form { $this->addElement('submit', $this->_csvButtonName, $label); } - if (CRM_Core_Permission::check('administer Reports') && $this->_add2groupSupported) { + if (CRM_Core_Permission::check('administer Reports') && + $this->_add2groupSupported + ) { $this->addElement('select', 'groups', ts('Group'), - array('' => ts('Add Contacts to Group')) + CRM_Core_PseudoConstant::nestedGroup(), + array('' => ts('Add Contacts to Group')) + + CRM_Core_PseudoConstant::nestedGroup(), array('class' => 'crm-select2 crm-action-menu action-icon-plus huge') ); $this->assign('group', TRUE); @@ -1145,7 +1196,9 @@ class CRM_Report_Form extends CRM_Core_Form { //add form rule for report if (is_callable(array( - $this, 'formRule'))) { + $this, + 'formRule' + ))) { $this->addFormRule(array(get_class($this), 'formRule'), $this); } } @@ -1159,11 +1212,16 @@ class CRM_Report_Form extends CRM_Core_Form { * * @return array */ - function customDataFormRule($fields, $ignoreFields = array( )) { + function customDataFormRule($fields, $ignoreFields = array()) { $errors = array(); - if (!empty($this->_customGroupExtends) && $this->_customGroupGroupBy && !empty($fields['group_bys'])) { + if (!empty($this->_customGroupExtends) && $this->_customGroupGroupBy && + !empty($fields['group_bys']) + ) { foreach ($this->_columns as $tableName => $table) { - if ((substr($tableName, 0, 13) == 'civicrm_value' || substr($tableName, 0, 12) == 'custom_value') && !empty($this->_columns[$tableName]['fields'])) { + if ((substr($tableName, 0, 13) == 'civicrm_value' || + substr($tableName, 0, 12) == 'custom_value') && + !empty($this->_columns[$tableName]['fields']) + ) { foreach ($this->_columns[$tableName]['fields'] as $fieldName => $field) { if (array_key_exists($fieldName, $fields['group_bys']) && !array_key_exists($fieldName, $fields['fields']) @@ -1172,7 +1230,9 @@ class CRM_Report_Form extends CRM_Core_Form { } elseif (array_key_exists($fieldName, $fields['group_bys'])) { foreach ($fields['fields'] as $fld => $val) { - if (!array_key_exists($fld, $fields['group_bys']) && !in_array($fld, $ignoreFields)) { + if (!array_key_exists($fld, $fields['group_bys']) && + !in_array($fld, $ignoreFields) + ) { $errors['fields'] = "Please ensure that fields selected in 'Display Columns' are also selected in 'Group by Columns' section."; } } @@ -1261,10 +1321,8 @@ class CRM_Report_Form extends CRM_Core_Form { if (!empty($contactTags)) { $this->_columns['civicrm_tag'] = array( 'dao' => 'CRM_Core_DAO_Tag', - 'filters' => - array( - 'tagid' => - array( + 'filters' => array( + 'tagid' => array( 'name' => 'tag_id', 'title' => ts('Tag'), 'tag' => TRUE, @@ -1281,8 +1339,7 @@ class CRM_Report_Form extends CRM_Core_Form { */ function buildGroupFilter() { $this->_columns['civicrm_group']['filters'] = array( - 'gid' => - array( + 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -1355,7 +1412,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @return null|string */ function whereClause(&$field, $op, - $value, $min, $max + $value, $min, $max ) { $type = CRM_Utils_Type::typeToString(CRM_Utils_Array::value('type', $field)); @@ -1367,8 +1424,8 @@ class CRM_Report_Form extends CRM_Core_Form { if (($min !== NULL && strlen($min) > 0) || ($max !== NULL && strlen($max) > 0) ) { - $min = CRM_Utils_Type::escape($min, $type); - $max = CRM_Utils_Type::escape($max, $type); + $min = CRM_Utils_Type::escape($min, $type); + $max = CRM_Utils_Type::escape($max, $type); $clauses = array(); if ($min) { if ($op == 'bw') { @@ -1420,16 +1477,21 @@ class CRM_Report_Form extends CRM_Core_Form { } if ($value !== NULL && is_array($value) && count($value) > 0) { $sqlOP = $this->getSQLOperator($op); - if (CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_STRING) { + if (CRM_Utils_Array::value('type', $field) == + CRM_Utils_Type::T_STRING + ) { //cycle through selections and esacape values foreach ($value as $key => $selection) { $value[$key] = CRM_Utils_Type::escape($selection, $type); } - $clause = "( {$field['dbAlias']} $sqlOP ( '" . implode("' , '", $value) . "') )"; + $clause = + "( {$field['dbAlias']} $sqlOP ( '" . implode("' , '", $value) . + "') )"; } else { // for numerical values - $clause = "{$field['dbAlias']} $sqlOP (" . implode(', ', $value) . ")"; + $clause = "{$field['dbAlias']} $sqlOP (" . implode(', ', $value) . + ")"; } if ($op == 'notin') { $clause = "( " . $clause . " OR {$field['dbAlias']} IS NULL )"; @@ -1444,7 +1506,9 @@ class CRM_Report_Form extends CRM_Core_Form { // mhas == multiple has if ($value !== NULL && count($value) > 0) { $sqlOP = $this->getSQLOperator($op); - $clause = "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) . "[[:>:]]'"; + $clause = + "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) . + "[[:>:]]'"; } break; @@ -1452,7 +1516,9 @@ class CRM_Report_Form extends CRM_Core_Form { // mnot == multiple is not one of if ($value !== NULL && count($value) > 0) { $sqlOP = $this->getSQLOperator($op); - $clause = "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) . "[[:>:]]' OR {$field['dbAlias']} IS NULL )"; + $clause = + "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) . + "[[:>:]]' OR {$field['dbAlias']} IS NULL )"; } break; @@ -1531,7 +1597,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @return null|string */ function dateClause($fieldName, - $relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL + $relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL ) { $clauses = array(); if (in_array($relative, array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)))) { @@ -1557,13 +1623,16 @@ class CRM_Report_Form extends CRM_Core_Form { return NULL; } - /** - * @todo - could not find any instances where this is called - * @param unknown_type $relative - * @param String $from - * @param String_type $to - * @return string|NULL - */ + + /** + * @todo - could not find any instances where this is called + * + * @param unknown_type $relative + * @param String $from + * @param String_type $to + * + * @return string|NULL + */ function dateDisplay($relative, $from, $to) { list($from, $to) = $this->getFromTo($relative, $from, $to); @@ -1641,7 +1710,13 @@ class CRM_Report_Form extends CRM_Core_Form { } $customFields = $fieldValueMap = array(); - $customFieldCols = array('column_name', 'data_type', 'html_type', 'option_group_id', 'id'); + $customFieldCols = array( + 'column_name', + 'data_type', + 'html_type', + 'option_group_id', + 'id' + ); // skip for type date and ContactReference since date format is already handled $query = " @@ -1659,7 +1734,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { foreach ($customFieldCols as $key) { - $customFields[$dao->table_name . '_custom_' . $dao->id][$key] = $dao->$key; + $customFields[$dao->table_name . '_custom_' . + $dao->id][$key] = $dao->$key; } if ($dao->option_group_id) { $fieldValueMap[$dao->option_group_id][$dao->value] = $dao->label; @@ -1722,27 +1798,22 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND case 'Float': if ($htmlType == 'Text') { - $retValue = (float)$value; + $retValue = (float) $value; break; } case 'Money': if ($htmlType == 'Text') { - - - - - - - $retValue = CRM_Utils_Money::format($value, NULL, '%a'); break; } case 'String': case 'Int': if (in_array($htmlType, array( - 'Text', 'TextArea'))) { + 'Text', + 'TextArea' + ))) { $retValue = $value; break; } @@ -1823,7 +1894,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND foreach ($rows as $key => $list) { foreach ($list as $colName => $colVal) { if (array_key_exists($colName, $checkList) && - $checkList[$colName] == $colVal) { + $checkList[$colName] == $colVal + ) { $rows[$key][$colName] = ""; } if (in_array($colName, $this->_noRepeats)) { @@ -1898,7 +1970,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if (!empty($this->_params['charts']) && !empty($rows)) { $this->buildChart($rows); $this->assign('chartEnabled', TRUE); - $this->_chartId = "{$this->_params['charts']}_" . ($this->_id ? $this->_id : substr(get_class($this), 16)) . '_' . session_id(); + $this->_chartId = "{$this->_params['charts']}_" . + ($this->_id ? $this->_id : substr(get_class($this), 16)) . '_' . + session_id(); $this->assign('chartId', $this->_chartId); } @@ -1958,7 +2032,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $this->_phoneField = TRUE; } - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // 1. In many cases we want select clause to be built in slightly different way // for a particular field of a particular type. @@ -2044,40 +2120,44 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND continue; } - if (!empty($this->_params['group_bys']) && !empty($this->_params['group_bys'][$fieldName]) && !empty($this->_params['group_bys_freq'])) { + if (!empty($this->_params['group_bys']) && + !empty($this->_params['group_bys'][$fieldName]) && + !empty($this->_params['group_bys_freq']) + ) { switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { case 'YEARWEEK': - $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; + $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Week'; break; case 'YEAR': - $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Year'; break; case 'MONTH': - $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; - $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; + $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Month'; break; case 'QUARTER': - $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Quarter'; break; } // for graphs and charts - if (!empty($this->_params['group_bys_freq'][$fieldName])) { $this->_interval = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning'; + $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = + $field['title'] . ' Beginning'; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type']; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName]; @@ -2135,31 +2215,35 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * temp table that may not be part of the final where clause or added * in other functions */ - function storeWhereHavingClauseArray(){ + function storeWhereHavingClauseArray() { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { // respect pseudofield to filter spec so fields can be marked as // not to be handled here - if(!empty($field['pseudofield'])){ + if (!empty($field['pseudofield'])) { continue; } $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - if (CRM_Utils_Array::value('operatorType', $field) == CRM_Report_Form::OP_MONTH) { + if (CRM_Utils_Array::value('operatorType', $field) == + CRM_Report_Form::OP_MONTH + ) { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); if (is_array($value) && !empty($value)) { - $clause = "(month({$field['dbAlias']}) $op (" . implode(', ', $value) . '))'; + $clause = + "(month({$field['dbAlias']}) $op (" . implode(', ', $value) . + '))'; } } else { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params); - $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params); - $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime); + $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params); + $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime); } } else { @@ -2187,6 +2271,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } } + function processReportMode() { $buttonName = $this->controller->getButtonName(); @@ -2207,14 +2292,16 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $printOnly = FALSE; $this->assign('printOnly', FALSE); - if ($this->_printButtonName == $buttonName || $output == 'print' || ($this->_sendmail && !$output)) { + if ($this->_printButtonName == $buttonName || $output == 'print' || + ($this->_sendmail && !$output) + ) { $this->assign('printOnly', TRUE); $printOnly = TRUE; $this->assign('outputMode', 'print'); $this->_outputMode = 'print'; if ($this->_sendmail) { $this->_absoluteUrl = TRUE; - } + } } elseif ($this->_pdfButtonName == $buttonName || $output == 'pdf') { $this->assign('printOnly', TRUE); @@ -2273,7 +2360,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $this->_formValues = $this->_params; if (CRM_Core_Permission::check('administer Reports') && isset($this->_id) && - ($this->_instanceButtonName == $this->controller->getButtonName() . '_save' || + ($this->_instanceButtonName == + $this->controller->getButtonName() . '_save' || $this->_chartButtonName == $this->controller->getButtonName() ) ) { @@ -2341,10 +2429,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } function orderBy() { - $this->_orderBy = ""; + $this->_orderBy = ""; $this->_sections = array(); $this->storeOrderByArray(); - if(!empty($this->_orderByArray) && !$this->_rollup == 'WITH ROLLUP'){ + if (!empty($this->_orderByArray) && !$this->_rollup == 'WITH ROLLUP') { $this->_orderBy = "ORDER BY " . implode(', ', $this->_orderByArray); } $this->assign('sections', $this->_sections); @@ -2356,7 +2444,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * the order by clause */ function storeOrderByArray() { - $orderBys = array(); + $orderBys = array(); if (!empty($this->_params['order_bys']) && is_array($this->_params['order_bys']) && @@ -2412,7 +2500,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $selectColumns["{$tableName}_{$fieldName}"] = 1; } @@ -2493,7 +2583,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND */ - $query = "select " . implode(", ", $ifnulls) . ", count(*) as ct from ($sql) as subquery group by " . implode(", ", $sectionAliases); + $query = "select " . implode(", ", $ifnulls) . + ", count(*) as ct from ($sql) as subquery group by " . + implode(", ", $sectionAliases); // initialize array of total counts $totals = array(); @@ -2506,8 +2598,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $row = $rows[0]; // add totals for all permutations of section values - $values = array(); - $i = 1; + $values = array(); + $i = 1; $aliasCount = count($sectionAliases); foreach ($sectionAliases as $alias) { $values[] = $row[$alias]; @@ -2568,13 +2660,15 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @param $count */ function countStat(&$statistics, $count) { - $statistics['counts']['rowCount'] = array('title' => ts('Row(s) Listed'), - 'value' => $count, + $statistics['counts']['rowCount'] = array( + 'title' => ts('Row(s) Listed'), + 'value' => $count, ); if ($this->_rowsFound && ($this->_rowsFound > $count)) { - $statistics['counts']['rowsFound'] = array('title' => ts('Total Row(s)'), - 'value' => $this->_rowsFound, + $statistics['counts']['rowsFound'] = array( + 'title' => ts('Total Row(s)'), + 'value' => $this->_rowsFound, ); } } @@ -2596,8 +2690,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } } } - $statistics['groups'][] = array('title' => ts('Grouping(s)'), - 'value' => implode(' & ', $combinations), + $statistics['groups'][] = array( + 'title' => ts('Grouping(s)'), + 'value' => implode(' & ', $combinations), ); } } @@ -2609,7 +2704,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { - if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE && CRM_Utils_Array::value('operatorType', $field) != CRM_Report_Form::OP_MONTH) { + if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE && + CRM_Utils_Array::value('operatorType', $field) != + CRM_Report_Form::OP_MONTH + ) { list($from, $to) = $this->getFromTo( CRM_Utils_Array::value("{$fieldName}_relative", $this->_params), @@ -2619,10 +2717,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params) ); $from_time_format = !empty($this->_params["{$fieldName}_from_time"]) ? 'h' : 'd'; - $from = CRM_Utils_Date::customFormat($from, null, array($from_time_format)); + $from = CRM_Utils_Date::customFormat($from, NULL, array($from_time_format)); $to_time_format = !empty($this->_params["{$fieldName}_to_time"]) ? 'h' : 'd'; - $to = CRM_Utils_Date::customFormat($to, null, array($to_time_format)); + $to = CRM_Utils_Date::customFormat($to, NULL, array($to_time_format)); if ($from || $to) { $statistics['filters'][] = array( @@ -2631,8 +2729,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND ); } elseif (in_array($rel = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params), - array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)) - )) { + array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)) + )) { $pair = $this->getOperationPair(CRM_Report_Form::OP_DATE); $statistics['filters'][] = array( 'title' => $field['title'], @@ -2654,9 +2752,13 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if (in_array($op, array('bw', 'nbw')) && ($min || $max)) { $value = "{$pair[$op]} $min " . ts('and') . " $max"; } - elseif ($val && CRM_Utils_Array::value('operatorType', $field) & self::OP_ENTITYREF) { + elseif ($val && CRM_Utils_Array::value('operatorType', $field) & + self::OP_ENTITYREF + ) { $this->setEntityRefDefaults($field, $tableName); - $result = civicrm_api3($field['attributes']['entity'], 'getlist', array('id' => $val) + CRM_Utils_Array::value('api', $field['attributes'], array())); + $result = civicrm_api3($field['attributes']['entity'], 'getlist', + array('id' => $val) + + CRM_Utils_Array::value('api', $field['attributes'], array())); $values = array(); foreach ($result['values'] as $v) { $values[] = $v['label']; @@ -2673,22 +2775,26 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $val[$key] = $options[$valIds]; } } - $pair[$op] = (count($val) == 1) ? (($op == 'notin' || $op == 'mnot') ? ts('Is Not') : ts('Is')) : CRM_Utils_Array::value($op, $pair); - $val = implode(', ', $val); - $value = "{$pair[$op]} " . $val; + $pair[$op] = (count($val) == 1) ? (($op == 'notin' || $op == + 'mnot') ? ts('Is Not') : ts('Is')) : CRM_Utils_Array::value($op, $pair); + $val = implode(', ', $val); + $value = "{$pair[$op]} " . $val; } - elseif (!is_array($val) && (!empty($val) || $val == '0') && isset($field['options']) && + elseif (!is_array($val) && (!empty($val) || $val == '0') && + isset($field['options']) && is_array($field['options']) && !empty($field['options']) ) { - $value = CRM_Utils_Array::value($op, $pair) . " " . CRM_Utils_Array::value($val, $field['options'], $val); + $value = CRM_Utils_Array::value($op, $pair) . " " . + CRM_Utils_Array::value($val, $field['options'], $val); } elseif ($val) { $value = CRM_Utils_Array::value($op, $pair) . " " . $val; } } if ($value) { - $statistics['filters'][] = array('title' => CRM_Utils_Array::value('title', $field), - 'value' => $value, + $statistics['filters'][] = array( + 'title' => CRM_Utils_Array::value('title', $field), + 'value' => $value, ); } } @@ -2701,7 +2807,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @param null $rows */ function endPostProcess(&$rows = NULL) { - if ( $this->_storeResultSet ) { + if ($this->_storeResultSet) { $this->_resultSet = $rows; } @@ -2712,7 +2818,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $content = $this->compileContent(); $url = CRM_Utils_System::url("civicrm/report/instance/{$this->_id}", - "reset=1", TRUE + "reset=1", TRUE ); if ($this->_sendmail) { @@ -2720,9 +2826,14 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $attachments = array(); if ($this->_outputMode == 'csv') { - $content = $this->_formValues['report_header'] . '

' . ts('Report URL') . ": {$url}

" . '

' . ts('The report is attached as a CSV file.') . '

' . $this->_formValues['report_footer']; - - $csvFullFilename = $config->templateCompileDir . CRM_Utils_File::makeFileName('CiviReport.csv'); + $content = + $this->_formValues['report_header'] . '

' . ts('Report URL') . + ": {$url}

" . '

' . + ts('The report is attached as a CSV file.') . '

' . + $this->_formValues['report_footer']; + + $csvFullFilename = $config->templateCompileDir . + CRM_Utils_File::makeFileName('CiviReport.csv'); $csvContent = CRM_Report_Utils_Report::makeCsv($this, $rows); file_put_contents($csvFullFilename, $csvContent); $attachments[] = array( @@ -2733,14 +2844,19 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } if ($this->_outputMode == 'pdf') { // generate PDF content - $pdfFullFilename = $config->templateCompileDir . CRM_Utils_File::makeFileName('CiviReport.pdf'); + $pdfFullFilename = $config->templateCompileDir . + CRM_Utils_File::makeFileName('CiviReport.pdf'); file_put_contents($pdfFullFilename, CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", TRUE, array('orientation' => 'landscape') ) ); // generate Email Content - $content = $this->_formValues['report_header'] . '

' . ts('Report URL') . ": {$url}

" . '

' . ts('The report is attached as a PDF file.') . '

' . $this->_formValues['report_footer']; + $content = + $this->_formValues['report_header'] . '

' . ts('Report URL') . + ": {$url}

" . '

' . + ts('The report is attached as a PDF file.') . '

' . + $this->_formValues['report_footer']; $attachments[] = array( 'fullPath' => $pdfFullFilename, @@ -2750,8 +2866,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } if (CRM_Report_Utils_Report::mailReport($content, $this->_id, - $this->_outputMode, $attachments - )) { + $this->_outputMode, $attachments + ) + ) { CRM_Core_Session::setStatus(ts("Report mail has been sent."), ts('Sent'), 'success'); } else { @@ -2768,10 +2885,14 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND //get chart image name $chartImg = $this->_chartId . '.png'; //get image url path - $uploadUrl = str_replace('/persist/contribute/', '/persist/', $config->imageUploadURL) . 'openFlashChart/'; + $uploadUrl = + str_replace('/persist/contribute/', '/persist/', $config->imageUploadURL) . + 'openFlashChart/'; $uploadUrl .= $chartImg; //get image doc path to overwrite - $uploadImg = str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) . 'openFlashChart/' . $chartImg; + $uploadImg = + str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) . + 'openFlashChart/' . $chartImg; //Load the image $chart = imagecreatefrompng($uploadUrl); //convert it into formattd png @@ -2796,7 +2917,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND CRM_Report_Form_Instance::postProcess($this); } elseif ($this->_createNewButtonName == $this->controller->getButtonName() || - $this->_outputMode == 'create_report' ) { + $this->_outputMode == 'create_report' + ) { $this->_createNew = TRUE; CRM_Report_Form_Instance::postProcess($this); } @@ -2826,9 +2948,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND /** * @return string */ - function getTemplateFileName(){ + function getTemplateFileName() { $defaultTpl = parent::getTemplateFileName(); - $template = CRM_Core_Smarty::singleton(); + $template = CRM_Core_Smarty::singleton(); if (!$template->template_exists($defaultTpl)) { $defaultTpl = 'CRM/Report/Form.tpl'; } @@ -2843,9 +2965,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND /** * @return string */ - function compileContent(){ + function compileContent() { $templateFile = $this->getHookedTemplateFileName(); - return $this->_formValues['report_header'] . CRM_Core_Form::$_template->fetch($templateFile) . $this->_formValues['report_footer']; + return $this->_formValues['report_header'] . + CRM_Core_Form::$_template->fetch($templateFile) . + $this->_formValues['report_footer']; } @@ -2889,10 +3013,10 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if (!$pageId && !empty($_POST)) { if (isset($_POST['PagerBottomButton']) && isset($_POST['crmPID_B'])) { - $pageId = max((int)@$_POST['crmPID_B'], 1); + $pageId = max((int) @$_POST['crmPID_B'], 1); } elseif (isset($_POST['PagerTopButton']) && isset($_POST['crmPID'])) { - $pageId = max((int)@$_POST['crmPID'], 1); + $pageId = max((int) @$_POST['crmPID'], 1); } unset($_POST['crmPID_B'], $_POST['crmPID']); } @@ -2907,8 +3031,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $this->_limit = " LIMIT $offset, $rowCount"; return array($offset, $rowCount); } - if($this->_limitValue) { - if($this->_offsetValue) { + if ($this->_limitValue) { + if ($this->_offsetValue) { $this->_limit = " LIMIT {$this->_offsetValue}, {$this->_limitValue} "; } else { @@ -2928,9 +3052,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } if ($this->_limit && ($this->_limit != '')) { - $sql = "SELECT FOUND_ROWS();"; + $sql = "SELECT FOUND_ROWS();"; $this->_rowsFound = CRM_Core_DAO::singleValueQuery($sql); - $params = array( + $params = array( 'total' => $this->_rowsFound, 'rowCount' => $rowCount, 'status' => ts('Records') . ' %%StatusMessage%%', @@ -2961,7 +3085,9 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $group->find(); $smartGroups = array(); while ($group->fetch()) { - if (in_array($group->id, $this->_params['gid_value']) && $group->saved_search_id) { + if (in_array($group->id, $this->_params['gid_value']) && + $group->saved_search_id + ) { $smartGroups[] = $group->id; } } @@ -3025,11 +3151,12 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND FROM civicrm_membership mem LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id - WHERE mt.member_of_contact_id IN (".$tmp_membership_org_sql_list.") + WHERE mt.member_of_contact_id IN (" . + $tmp_membership_org_sql_list . ") AND mt.is_active = '1' AND mem_status.is_current_member = '1' AND mem_status.is_active = '1' ) "; - } + } function whereMembershipTypeClause($field, $value, $op) { $sqlOp = $this->getSQLOperator($op); @@ -3037,13 +3164,14 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $value = array($value); } - $tmp_membership_sql_list = implode(', ', $value); + $tmp_membership_sql_list = implode(', ', $value); return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} ( SELECT DISTINCT mem.contact_id FROM civicrm_membership mem LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id - WHERE mem.membership_type_id IN (".$tmp_membership_sql_list.") + WHERE mem.membership_type_id IN (" . + $tmp_membership_sql_list . ") AND mt.is_active = '1' AND mem_status.is_current_member = '1' AND mem_status.is_active = '1' ) "; @@ -3069,7 +3197,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } $customGroupWhere = ''; if (!empty($permCustomGroupIds)) { - $customGroupWhere = "cg.id IN (".implode(',' , $permCustomGroupIds).") AND"; + $customGroupWhere = "cg.id IN (" . implode(',', $permCustomGroupIds) . + ") AND"; } $sql = " SELECT cg.table_name, cg.title, cg.extends, cf.id as cf_id, cf.label, @@ -3097,7 +3226,10 @@ ORDER BY cg.weight, cf.weight"; $this->_columns[$curTable]['group_title'] = $customDAO->title; foreach (array( - 'fields', 'filters', 'group_bys') as $colKey) { + 'fields', + 'filters', + 'group_bys' + ) as $colKey) { if (!array_key_exists($colKey, $this->_columns[$curTable])) { $this->_columns[$curTable][$colKey] = array(); } @@ -3137,9 +3269,10 @@ ORDER BY cg.weight, cf.weight"; case 'Boolean': $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT; - $curFilters[$fieldName]['options'] = array('' => ts('- select -'), - 1 => ts('Yes'), - 0 => ts('No'), + $curFilters[$fieldName]['options'] = array( + '' => ts('- select -'), + 1 => ts('Yes'), + 0 => ts('No'), ); $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_INT; break; @@ -3164,7 +3297,10 @@ ORDER BY cg.weight, cf.weight"; if (!empty($customDAO->option_group_id)) { if (in_array($customDAO->html_type, array( - 'Multi-Select', 'AdvMulti-Select', 'CheckBox'))) { + 'Multi-Select', + 'AdvMulti-Select', + 'CheckBox' + ))) { $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT_SEPARATOR; } else { @@ -3172,7 +3308,12 @@ ORDER BY cg.weight, cf.weight"; } if ($this->_customGroupFilters) { $curFilters[$fieldName]['options'] = array(); - $ogDAO = CRM_Core_DAO::executeQuery("SELECT ov.value, ov.label FROM civicrm_option_value ov WHERE ov.option_group_id = %1 ORDER BY ov.weight", array(1 => array($customDAO->option_group_id, 'Integer'))); + $ogDAO = CRM_Core_DAO::executeQuery("SELECT ov.value, ov.label FROM civicrm_option_value ov WHERE ov.option_group_id = %1 ORDER BY ov.weight", array( + 1 => array( + $customDAO->option_group_id, + 'Integer' + ) + )); while ($ogDAO->fetch()) { $curFilters[$fieldName]['options'][$ogDAO->value] = $ogDAO->label; } @@ -3182,7 +3323,8 @@ ORDER BY cg.weight, cf.weight"; case 'StateProvince': if (in_array($customDAO->html_type, array( - 'Multi-Select State/Province'))) { + 'Multi-Select State/Province' + ))) { $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT_SEPARATOR; } else { @@ -3193,7 +3335,8 @@ ORDER BY cg.weight, cf.weight"; case 'Country': if (in_array($customDAO->html_type, array( - 'Multi-Select Country'))) { + 'Multi-Select Country' + ))) { $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT_SEPARATOR; } else { @@ -3240,7 +3383,9 @@ ORDER BY cg.weight, cf.weight"; $mapper = CRM_Core_BAO_CustomQuery::$extendsMap; foreach ($this->_columns as $table => $prop) { - if (substr($table, 0, 13) == 'civicrm_value' || substr($table, 0, 12) == 'custom_value') { + if (substr($table, 0, 13) == 'civicrm_value' || + substr($table, 0, 12) == 'custom_value' + ) { $extendsTable = $mapper[$prop['extends']]; // check field is in params @@ -3249,13 +3394,15 @@ ORDER BY cg.weight, cf.weight"; } $baseJoin = CRM_Utils_Array::value($prop['extends'], $this->_customGroupExtendsJoin, "{$this->_aliases[$extendsTable]}.id"); - $customJoin = is_array($this->_customGroupJoin) ? $this->_customGroupJoin[$table] : $this->_customGroupJoin; + $customJoin = is_array($this->_customGroupJoin) ? $this->_customGroupJoin[$table] : $this->_customGroupJoin; $this->_from .= " {$customJoin} {$table} {$this->_aliases[$table]} ON {$this->_aliases[$table]}.entity_id = {$baseJoin}"; // handle for ContactReference if (array_key_exists('fields', $prop)) { foreach ($prop['fields'] as $fieldName => $field) { - if (CRM_Utils_Array::value('dataType', $field) == 'ContactReference') { + if (CRM_Utils_Array::value('dataType', $field) == + 'ContactReference' + ) { $columnName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', CRM_Core_BAO_CustomField::getKeyID($fieldName), 'column_name'); $this->_from .= " LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_aliases[$table]}.{$columnName} "; @@ -3285,7 +3432,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } //might be survey response field. - if (!empty($this->_params['fields']['survey_response']) && !empty($prop['fields'][$fieldAlias]['isSurveyResponseField'])) { + if (!empty($this->_params['fields']['survey_response']) && + !empty($prop['fields'][$fieldAlias]['isSurveyResponseField']) + ) { return TRUE; } } @@ -3294,7 +3443,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if (!empty($this->_params['group_bys']) && $this->_customGroupGroupBy) { foreach (array_keys($prop['group_bys']) as $fieldAlias) { - if (array_key_exists($fieldAlias, $this->_params['group_bys']) && CRM_Core_BAO_CustomField::getKeyID($fieldAlias)) { + if (array_key_exists($fieldAlias, $this->_params['group_bys']) && + CRM_Core_BAO_CustomField::getKeyID($fieldAlias) + ) { return TRUE; } } @@ -3303,7 +3454,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if (!empty($this->_params['order_bys'])) { foreach (array_keys($prop['fields']) as $fieldAlias) { foreach ($this->_params['order_bys'] as $orderBy) { - if ($fieldAlias == $orderBy['column'] && CRM_Core_BAO_CustomField::getKeyID($fieldAlias)) { + if ($fieldAlias == $orderBy['column'] && + CRM_Core_BAO_CustomField::getKeyID($fieldAlias) + ) { return TRUE; } } @@ -3313,12 +3466,19 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if (!empty($prop['filters']) && $this->_customGroupFilters) { foreach ($prop['filters'] as $fieldAlias => $val) { foreach (array( - 'value', 'min', 'max', 'relative', 'from', 'to') as $attach) { + 'value', + 'min', + 'max', + 'relative', + 'from', + 'to' + ) as $attach) { if (isset($this->_params[$fieldAlias . '_' . $attach]) && (!empty($this->_params[$fieldAlias . '_' . $attach]) - || ($attach != 'relative' && $this->_params[$fieldAlias . '_' . $attach] == '0') + || ($attach != 'relative' && + $this->_params[$fieldAlias . '_' . $attach] == '0') ) - ){ + ) { return TRUE; } } @@ -3376,7 +3536,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a /** * Does table name have columns in SELECT clause? * - * @param string $tableName Name of table (index of $this->_columns array) + * @param string $tableName Name of table (index of $this->_columns array) * * @return bool */ @@ -3393,7 +3553,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a function selectedTables() { if (!$this->_selectedTables) { $orderByColumns = array(); - if (array_key_exists('order_bys', $this->_params) && is_array($this->_params['order_bys'])) { + if (array_key_exists('order_bys', $this->_params) && + is_array($this->_params['order_bys']) + ) { foreach ($this->_params['order_bys'] as $orderBy) { $orderByColumns[] = $orderBy['column']; } @@ -3402,7 +3564,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $this->_selectedTables[] = $tableName; break; } @@ -3419,8 +3583,10 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $filterName => $filter) { if (!empty($this->_params["{$filterName}_value"]) || - CRM_Utils_Array::value("{$filterName}_op", $this->_params) == 'nll' || - CRM_Utils_Array::value("{$filterName}_op", $this->_params) == 'nnll' + CRM_Utils_Array::value("{$filterName}_op", $this->_params) == + 'nll' || + CRM_Utils_Array::value("{$filterName}_op", $this->_params) == + 'nnll' ) { $this->_selectedTables[] = $tableName; break; @@ -3447,72 +3613,67 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a */ function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = TRUE, $defaults = array('country_id' => TRUE)) { $addressFields = array( - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( - 'name' => - array('title' => ts('Address Name'), + 'fields' => array( + 'name' => array( + 'title' => ts('Address Name'), 'default' => CRM_Utils_Array::value('name', $defaults, FALSE), ), - 'street_address' => - array('title' => ts('Street Address'), + 'street_address' => array( + 'title' => ts('Street Address'), 'default' => CRM_Utils_Array::value('street_address', $defaults, FALSE), ), - 'supplemental_address_1' => - array('title' => ts('Supplementary Address Field 1'), + 'supplemental_address_1' => array( + 'title' => ts('Supplementary Address Field 1'), 'default' => CRM_Utils_Array::value('supplemental_address_1', $defaults, FALSE), ), - 'supplemental_address_2' => - array('title' => ts('Supplementary Address Field 2'), + 'supplemental_address_2' => array( + 'title' => ts('Supplementary Address Field 2'), 'default' => CRM_Utils_Array::value('supplemental_address_2', $defaults, FALSE), ), - 'street_number' => - array( + 'street_number' => array( 'name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_number', $defaults, FALSE), ), - 'street_name' => - array( + 'street_name' => array( 'name' => 'street_name', 'title' => ts('Street Name'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_name', $defaults, FALSE), ), - 'street_unit' => - array( + 'street_unit' => array( 'name' => 'street_unit', 'title' => ts('Street Unit'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_unit', $defaults, FALSE), ), - 'city' => - array('title' => ts('City'), + 'city' => array( + 'title' => ts('City'), 'default' => CRM_Utils_Array::value('city', $defaults, FALSE), ), - 'postal_code' => - array('title' => ts('Postal Code'), + 'postal_code' => array( + 'title' => ts('Postal Code'), 'default' => CRM_Utils_Array::value('postal_code', $defaults, FALSE), ), - 'postal_code_suffix' => - array('title' => ts('Postal Code Suffix'), + 'postal_code_suffix' => array( + 'title' => ts('Postal Code Suffix'), 'default' => CRM_Utils_Array::value('postal_code_suffix', $defaults, FALSE), ), - 'country_id' => - array('title' => ts('Country'), - 'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE), - ), - 'state_province_id' => - array('title' => ts('State/Province'), + 'country_id' => array( + 'title' => ts('Country'), + 'default' => CRM_Utils_Array::value('country_id', $defaults, FALSE), + ), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'default' => CRM_Utils_Array::value('state_province_id', $defaults, FALSE), ), - 'county_id' => - array('title' => ts('County'), - 'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE), - ), + 'county_id' => array( + 'title' => ts('County'), + 'default' => CRM_Utils_Array::value('county_id', $defaults, FALSE), + ), ), 'grouping' => 'location-fields', ), @@ -3520,28 +3681,31 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if ($filters) { $addressFields['civicrm_address']['filters'] = array( - 'street_number' => array('title' => ts('Street Number'), - 'type' => 1, - 'name' => 'street_number', + 'street_number' => array( + 'title' => ts('Street Number'), + 'type' => 1, + 'name' => 'street_number', ), - 'street_name' => array('title' => ts('Street Name'), - 'name' => 'street_name', - 'operator' => 'like', + 'street_name' => array( + 'title' => ts('Street Name'), + 'name' => 'street_name', + 'operator' => 'like', ), - 'postal_code' => array('title' => ts('Postal Code'), - 'type' => 1, - 'name' => 'postal_code', + 'postal_code' => array( + 'title' => ts('Postal Code'), + 'type' => 1, + 'name' => 'postal_code', ), - 'city' => array('title' => ts('City'), - 'operator' => 'like', - 'name' => 'city', + 'city' => array( + 'title' => ts('City'), + 'operator' => 'like', + 'name' => 'city', ), 'country_id' => array( 'name' => 'country_id', 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => - CRM_Report_Form::OP_MULTISELECT, + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), 'state_province_id' => array( @@ -3562,11 +3726,12 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } if ($orderBy) { - $addressFields['civicrm_address']['order_bys'] = array('street_name' => array('title' => ts('Street Name')), - 'street_number' => array('title' => 'Odd / Even Street Number'), - 'street_address' => NULL, - 'city' => NULL, - 'postal_code' => NULL, + $addressFields['civicrm_address']['order_bys'] = array( + 'street_name' => array('title' => ts('Street Name')), + 'street_number' => array('title' => 'Odd / Even Street Number'), + 'street_address' => NULL, + 'city' => NULL, + 'postal_code' => NULL, ); } @@ -3575,14 +3740,14 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), ), - 'county_id' => - array('title' => ts('County'), + 'county_id' => array( + 'title' => ts('County'), ), ); } @@ -3609,13 +3774,13 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if ($value = $row['civicrm_address_country_id']) { $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, - "reset=1&force=1&{$criteriaQueryParams}&" . - "country_id_op=in&country_id_value={$value}", - $this->_absoluteUrl, $this->_id + "reset=1&force=1&{$criteriaQueryParams}&" . + "country_id_op=in&country_id_value={$value}", + $this->_absoluteUrl, $this->_id ); $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 => $urltxt) ); } @@ -3625,13 +3790,13 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a if ($value = $row['civicrm_address_county_id']) { $rows[$rowNum]['civicrm_address_county_id'] = CRM_Core_PseudoConstant::county($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, - "reset=1&force=1&{$criteriaQueryParams}&" . - "county_id_op=in&county_id_value={$value}", - $this->_absoluteUrl, $this->_id + "reset=1&force=1&{$criteriaQueryParams}&" . + "county_id_op=in&county_id_value={$value}", + $this->_absoluteUrl, $this->_id ); $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 => $urltxt) ); } $entryFound = TRUE; @@ -3642,12 +3807,12 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE); $url = CRM_Report_Utils_Report::getNextUrl($baseUrl, - "reset=1&force=1&{$criteriaQueryParams}&state_province_id_op=in&state_province_id_value={$value}", - $this->_absoluteUrl, $this->_id + "reset=1&force=1&{$criteriaQueryParams}&state_province_id_op=in&state_province_id_value={$value}", + $this->_absoluteUrl, $this->_id ); $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 => $urltxt) ); } $entryFound = TRUE; @@ -3667,10 +3832,13 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a function fiscalYearOffset($fieldName) { $config = CRM_Core_Config::singleton(); $fy = $config->fiscalYearStart; - if (CRM_Utils_Array::value('yid_op', $this->_params) == 'calendar' || ($fy['d'] == 1 && $fy['M'] == 1)) { + if (CRM_Utils_Array::value('yid_op', $this->_params) == 'calendar' || + ($fy['d'] == 1 && $fy['M'] == 1) + ) { return "YEAR( $fieldName )"; } - return "YEAR( $fieldName - INTERVAL " . ($fy['M'] - 1) . " MONTH" . ($fy['d'] > 1 ? (" - INTERVAL " . ($fy['d'] - 1) . " DAY") : '') . " )"; + return "YEAR( $fieldName - INTERVAL " . ($fy['M'] - 1) . " MONTH" . + ($fy['d'] > 1 ? (" - INTERVAL " . ($fy['d'] - 1) . " DAY") : '') . " )"; } /* @@ -3708,26 +3876,28 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a /** * Get phone columns to add to array + * * @param array $options * - prefix Prefix to add to table (in case of more than one instance of the table) * - prefix_label Label to give columns from this phone table instance + * * @return array phone columns definition */ - function getPhoneColumns($options = array()){ + function getPhoneColumns($options = array()) { $defaultOptions = array( 'prefix' => '', 'prefix_label' => '', ); - $options = array_merge($defaultOptions,$options); + $options = array_merge($defaultOptions, $options); $fields = array( $options['prefix'] . 'civicrm_phone' => array( - 'dao' => 'CRM_Core_DAO_Phone', + 'dao' => 'CRM_Core_DAO_Phone', 'fields' => array( $options['prefix'] . 'phone' => array( 'title' => ts($options['prefix_label'] . 'Phone'), - 'name' => 'phone' + 'name' => 'phone' ), ), ), @@ -3737,9 +3907,11 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a /** * Get address columns to add to array + * * @param array $options * - prefix Prefix to add to table (in case of more than one instance of the table) * - prefix_label Label to give columns from this address table instance + * * @return array address columns definition */ function getAddressColumns($options = array()) { @@ -3778,7 +3950,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } - if ( !empty($contact_ids) ) { + if (!empty($contact_ids)) { CRM_Contact_BAO_GroupContact::addContactsToGroup($contact_ids, $groupID); CRM_Core_Session::setStatus(ts("Listed contact(s) have been added to the selected group."), ts('Contacts Added'), 'success'); } @@ -3802,7 +3974,9 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a // prepare the directory $config = CRM_Core_Config::singleton(); - $defaultPath = str_replace('/persist/contribute/' , '/persist/', $config->imageUploadDir) . '/openFlashChart/'; + $defaultPath = + str_replace('/persist/contribute/', '/persist/', $config->imageUploadDir) . + '/openFlashChart/'; if (!file_exists($defaultPath)) { mkdir($defaultPath, 0777, TRUE); } @@ -3820,6 +3994,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a /** * Apply common settings to entityRef fields + * * @param array $field * @param string $table */ diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index ef575eadb9..63fb194b34 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -64,215 +64,193 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { asort($this->activityTypes); $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'contact_source' => - array( - 'name' => 'sort_name', - 'title' => ts('Source Contact Name'), - 'alias' => 'civicrm_contact_source', - 'no_repeat' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'contact_source' => array( + 'name' => 'sort_name', + 'title' => ts('Source Contact Name'), + 'alias' => 'civicrm_contact_source', + 'no_repeat' => TRUE, + ), + 'contact_assignee' => array( + 'name' => 'sort_name', + 'title' => ts('Assignee Contact Name'), + 'alias' => 'civicrm_contact_assignee', + 'dbAlias' => "civicrm_contact_assignee.sort_name", + 'default' => TRUE, + ), + 'contact_target' => array( + 'name' => 'sort_name', + 'title' => ts('Target Contact Name'), + 'alias' => 'civicrm_contact_target', + 'dbAlias' => "civicrm_contact_target.sort_name", + 'default' => TRUE, + ), + 'contact_source_id' => array( + 'name' => 'id', + 'alias' => 'civicrm_contact_source', + 'dbAlias' => "civicrm_contact_source.id", + 'no_display' => TRUE, + 'default' => TRUE, + 'required' => TRUE, + ), + 'contact_assignee_id' => array( + 'name' => 'id', + 'alias' => 'civicrm_contact_assignee', + 'dbAlias' => "civicrm_contact_assignee.id", + 'no_display' => TRUE, + 'default' => TRUE, + 'required' => TRUE, + ), + 'contact_target_id' => array( + 'name' => 'id', + 'alias' => 'civicrm_contact_target', + 'dbAlias' => "civicrm_contact_target.id", + 'no_display' => TRUE, + 'default' => TRUE, + 'required' => TRUE, + ), ), - 'contact_assignee' => - array( - 'name' => 'sort_name', - 'title' => ts('Assignee Contact Name'), - 'alias' => 'civicrm_contact_assignee', - 'dbAlias' => "civicrm_contact_assignee.sort_name", - 'default' => TRUE, - ), - 'contact_target' => - array( - 'name' => 'sort_name', - 'title' => ts('Target Contact Name'), - 'alias' => 'civicrm_contact_target', - 'dbAlias' => "civicrm_contact_target.sort_name", - 'default' => TRUE, - ), - 'contact_source_id' => - array( - 'name' => 'id', - 'alias' => 'civicrm_contact_source', - 'dbAlias' => "civicrm_contact_source.id", - 'no_display' => TRUE, - 'default' => TRUE, - 'required' => TRUE, - ), - 'contact_assignee_id' => - array( - 'name' => 'id', - 'alias' => 'civicrm_contact_assignee', - 'dbAlias' => "civicrm_contact_assignee.id", - 'no_display' => TRUE, - 'default' => TRUE, - 'required' => TRUE, - ), - 'contact_target_id' => - array( - 'name' => 'id', - 'alias' => 'civicrm_contact_target', - 'dbAlias' => "civicrm_contact_target.id", - 'no_display' => TRUE, - 'default' => TRUE, - 'required' => TRUE, + 'filters' => array( + 'contact_source' => array( + 'name' => 'sort_name', + 'alias' => 'civicrm_contact_source', + 'title' => ts('Source Contact Name'), + 'operator' => 'like', + 'type' => CRM_Report_Form::OP_STRING, + ), + 'contact_assignee' => array( + 'name' => 'sort_name', + 'alias' => 'civicrm_contact_assignee', + 'title' => ts('Assignee Contact Name'), + 'operator' => 'like', + 'type' => CRM_Report_Form::OP_STRING, + ), + 'contact_target' => array( + 'name' => 'sort_name', + 'alias' => 'civicrm_contact_target', + 'title' => ts('Target Contact Name'), + 'operator' => 'like', + 'type' => CRM_Report_Form::OP_STRING, + ), + 'current_user' => array( + 'name' => 'current_user', + 'title' => ts('Limit To Current User'), + 'type' => CRM_Utils_Type::T_INT, + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => array('0' => ts('No'), '1' => ts('Yes')), + ), ), + 'grouping' => 'contact-fields', ), - 'filters' => - array( - 'contact_source' => - array( - 'name' => 'sort_name', - 'alias' => 'civicrm_contact_source', - 'title' => ts('Source Contact Name'), - 'operator' => 'like', - 'type' => CRM_Report_Form::OP_STRING, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'contact_source_email' => array( + 'name' => 'email', + 'title' => ts('Source Contact Email'), + 'alias' => 'civicrm_email_source', + ), + 'contact_assignee_email' => array( + 'name' => 'email', + 'title' => ts('Assignee Contact Email'), + 'alias' => 'civicrm_email_assignee', + ), + 'contact_target_email' => array( + 'name' => 'email', + 'title' => ts('Target Contact Email'), + 'alias' => 'civicrm_email_target', + ), ), - 'contact_assignee' => - array( - 'name' => 'sort_name', - 'alias' => 'civicrm_contact_assignee', - 'title' => ts('Assignee Contact Name'), - 'operator' => 'like', - 'type' => CRM_Report_Form::OP_STRING, - ), - 'contact_target' => - array( - 'name' => 'sort_name', - 'alias' => 'civicrm_contact_target', - 'title' => ts('Target Contact Name'), - 'operator' => 'like', - 'type' => CRM_Report_Form::OP_STRING, - ), - 'current_user' => - array( - 'name' => 'current_user', - 'title' => ts('Limit To Current User'), - 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('0' => ts('No'), '1' => ts('Yes')), + 'order_bys' => array( + 'source_contact_email' => array( + 'name' => 'email', + 'title' => ts('Source Contact Email'), + 'dbAlias' => 'civicrm_email_contact_source_email', + ), ), ), - 'grouping' => 'contact-fields', - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'contact_source_email' => - array( - 'name' => 'email', - 'title' => ts('Source Contact Email'), - 'alias' => 'civicrm_email_source', - ), - 'contact_assignee_email' => - array( - 'name' => 'email', - 'title' => ts('Assignee Contact Email'), - 'alias' => 'civicrm_email_assignee', - ), - 'contact_target_email' => - array( - 'name' => 'email', - 'title' => ts('Target Contact Email'), - 'alias' => 'civicrm_email_target', - ), - ), - 'order_bys' => - array( - 'source_contact_email' => - array( - 'name' => 'email', - 'title' => ts('Source Contact Email'), - 'dbAlias' => 'civicrm_email_contact_source_email', - ), - ), - ), - 'civicrm_activity' => - array( - 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array( - 'id' => - array( - 'no_display' => TRUE, - 'title' => ts('Activity ID'), - 'required' => TRUE, - ), - 'source_record_id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'activity_type_id' => - array('title' => ts('Activity Type'), - 'required' => TRUE, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'activity_subject' => - array('title' => ts('Subject'), - 'default' => TRUE, - ), - 'activity_date_time' => - array('title' => ts('Activity Date'), - 'required' => TRUE, + 'civicrm_activity' => array( + 'dao' => 'CRM_Activity_DAO_Activity', + 'fields' => array( + 'id' => array( + 'no_display' => TRUE, + 'title' => ts('Activity ID'), + 'required' => TRUE, + ), + 'source_record_id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), + 'required' => TRUE, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'activity_subject' => array( + 'title' => ts('Subject'), + 'default' => TRUE, + ), + 'activity_date_time' => array( + 'title' => ts('Activity Date'), + 'required' => TRUE, + ), + 'status_id' => array( + 'title' => ts('Activity Status'), + 'default' => TRUE, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'duration' => array( + 'title' => ts('Duration'), + 'type' => CRM_Utils_Type::T_INT, + ), + 'details' => array( + 'title' => ts('Activity Details'), + ) ), - 'status_id' => - array('title' => ts('Activity Status'), - 'default' => TRUE, - 'type' => CRM_Utils_Type::T_STRING, + 'filters' => array( + 'activity_date_time' => array( + 'default' => 'this.month', + 'operatorType' => CRM_Report_Form::OP_DATE, + ), + 'activity_subject' => array('title' => ts('Activity Subject')), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $this->activityTypes, + ), + 'status_id' => array( + 'title' => ts('Activity Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_PseudoConstant::activityStatus(), + ), + 'details' => array( + 'title' => ts('Activity Details'), + 'type' => CRM_Utils_Type::T_TEXT, + ) ), - 'duration' => - array('title' => ts('Duration'), - 'type' => CRM_Utils_Type::T_INT, + 'order_bys' => array( + 'activity_date_time' => array( + 'title' => ts('Activity Date'), + 'default_weight' => '1', + 'dbAlias' => 'civicrm_activity_activity_date_time' + ), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), + 'default_weight' => '2', + 'dbAlias' => 'civicrm_activity_activity_type_id' + ), ), - 'details' => array( - 'title' => ts('Activity Details'), - ) + 'grouping' => 'activity-fields', + 'alias' => 'activity', ), - 'filters' => array( - 'activity_date_time' => array( - 'default' => 'this.month', - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'activity_subject' => - array('title' => ts('Activity Subject')), - 'activity_type_id' => - array('title' => ts('Activity Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $this->activityTypes, - ), - 'status_id' => - array('title' => ts('Activity Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::activityStatus(), + 'civicrm_activity_contact' => array( + 'dao' => 'CRM_Activity_DAO_ActivityContact', + 'fields' => array(// so we have $this->_alias populated ), - 'details' => array( - 'title' => ts('Activity Details'), - 'type' => CRM_Utils_Type::T_TEXT, - ) ), - 'order_bys' => array( - 'activity_date_time' => - array('title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time'), - 'activity_type_id' => - array('title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => 'civicrm_activity_activity_type_id'), - ), - 'grouping' => 'activity-fields', - 'alias' => 'activity', - ), - 'civicrm_activity_contact' => - array( - 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - // so we have $this->_alias populated - ), - ), - ) + $this->addAddressFields(FALSE, TRUE); + ) + $this->addAddressFields(FALSE, TRUE); if ($campaignEnabled) { // Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled @@ -281,7 +259,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { 'title' => 'Survey Result', 'default' => 'false', ); - $this->_columns['civicrm_activity']['filters']['result'] = array('title' => ts('Survey Result'), + $this->_columns['civicrm_activity']['filters']['result'] = array( + 'title' => ts('Survey Result'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING, ); @@ -290,7 +269,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { 'title' => 'Campaign', 'default' => 'false', ); - $this->_columns['civicrm_activity']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_activity']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -300,7 +280,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { 'title' => 'Engagement Index', 'default' => 'false', ); - $this->_columns['civicrm_activity']['filters']['engagement_level'] = array('title' => ts('Engagement Index'), + $this->_columns['civicrm_activity']['filters']['engagement_level'] = array( + 'title' => ts('Engagement Index'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->engagementLevels, ); @@ -315,7 +296,9 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { * @param null $recordType */ function select($recordType = NULL) { - if (!array_key_exists("contact_{$recordType}", $this->_params['fields']) && $recordType != 'final') { + if (!array_key_exists("contact_{$recordType}", $this->_params['fields']) && + $recordType != 'final' + ) { $this->_nonDisplayFields[] = "civicrm_contact_contact_{$recordType}"; } parent::select(); @@ -342,7 +325,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { unset($this->_selectClauses[$key]); } } - } else if ($recordType == 'assignee') { + } + else if ($recordType == 'assignee') { foreach ($this->_selectClauses as $key => $clause) { if (strstr($clause, 'civicrm_contact_target.') || strstr($clause, 'civicrm_contact_source.') || @@ -353,7 +337,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { unset($this->_selectClauses[$key]); } } - } else if ($recordType == 'source') { + } + else if ($recordType == 'source') { foreach ($this->_selectClauses as $key => $clause) { if (strstr($clause, 'civicrm_contact_target.') || strstr($clause, 'civicrm_contact_assignee.') || @@ -364,12 +349,14 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { unset($this->_selectClauses[$key]); } } - } else if ($recordType == 'final') { + } + else if ($recordType == 'final') { $this->_selectClauses = $this->_selectAliasesTotal; foreach ($this->_selectClauses as $key => $clause) { if (strstr($clause, 'civicrm_contact_contact_target') || strstr($clause, 'civicrm_contact_contact_assignee') || - strstr($clause, 'civicrm_contact_contact_source') ) { + strstr($clause, 'civicrm_contact_contact_source') + ) { $this->_selectClauses[$key] = "GROUP_CONCAT($clause SEPARATOR ';') as $clause"; } } @@ -390,8 +377,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { function from($recordType) { $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); - $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); - $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); + $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); + $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); if ($recordType == 'target') { $this->_from = " @@ -476,8 +463,8 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { } if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } @@ -490,15 +477,21 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params) ); - if ($fieldName == 'activity_type_id' && empty($this->_params['activity_type_id_value'])) { + if ($fieldName == 'activity_type_id' && + empty($this->_params['activity_type_id_value']) + ) { $actTypes = array_flip(CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'label', TRUE)); - $clause = "( {$this->_aliases['civicrm_activity']}.activity_type_id IN (".implode(',',$actTypes).") )"; + $clause = + "( {$this->_aliases['civicrm_activity']}.activity_type_id IN (" . + implode(',', $actTypes) . ") )"; } } } if ($field['name'] == 'current_user') { - if (CRM_Utils_Array::value("{$fieldName}_value", $this->_params) == 1) { + if (CRM_Utils_Array::value("{$fieldName}_value", $this->_params) == + 1 + ) { // get current user $session = CRM_Core_Session::singleton(); if ($contactID = $session->get('userID')) { @@ -593,7 +586,7 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}"; } } - if ( !empty($contactIDs) ) { + if (!empty($contactIDs)) { CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIDs, $groupID); CRM_Core_Session::setStatus(ts("Listed contact(s) have been added to the selected group."), ts('Contacts Added'), 'success'); } @@ -608,22 +601,26 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}"; //Assign those recordtype to array which have filter operator as 'Is not empty' or 'Is empty' $nullFilters = array(); foreach (array('target', 'source', 'assignee') as $type) { - if (CRM_Utils_Array::value("contact_{$type}_op", $this->_params) == 'nnll' || !empty($this->_params["contact_{$type}_value"])) { + if (CRM_Utils_Array::value("contact_{$type}_op", $this->_params) == + 'nnll' || !empty($this->_params["contact_{$type}_value"]) + ) { $nullFilters[] = " civicrm_contact_contact_{$type}_id IS NOT NULL "; } - else if (CRM_Utils_Array::value("contact_{$type}_op", $this->_params) == 'nll') { + else if (CRM_Utils_Array::value("contact_{$type}_op", $this->_params) == + 'nll' + ) { $nullFilters[] = " civicrm_contact_contact_{$type}_id IS NULL "; } } - // 1. fill temp table with target results + // 1. fill temp table with target results $this->buildACLClause(array('civicrm_contact_target')); $this->select('target'); $this->from('target'); $this->customDataFrom(); $this->where('target'); $insertCols = implode(',', $this->_selectAliases); - $tempQuery = "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS + $tempQuery = "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS {$this->_select} {$this->_from} {$this->_where} "; CRM_Core_DAO::executeQuery($tempQuery); @@ -646,7 +643,7 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}"; $this->customDataFrom(); $this->where('assignee'); $insertCols = implode(',', $this->_selectAliases); - $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols}) + $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols}) {$this->_select} {$this->_from} {$this->_where}"; CRM_Core_DAO::executeQuery($tempQuery); @@ -658,7 +655,7 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}"; $this->customDataFrom(); $this->where('source'); $insertCols = implode(',', $this->_selectAliases); - $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols}) + $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols}) {$this->_select} {$this->_from} {$this->_where}"; CRM_Core_DAO::executeQuery($tempQuery); @@ -693,23 +690,25 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}" function alterDisplay(&$rows) { // custom code to alter rows - $entryFound = FALSE; - $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); + $entryFound = FALSE; + $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); - $viewLinks = FALSE; - $seperator = CRM_Core_DAO::VALUE_SEPARATOR; - $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report'); - $actUrl = ''; + $viewLinks = FALSE; + $seperator = CRM_Core_DAO::VALUE_SEPARATOR; + $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report'); + $actUrl = ''; if (CRM_Core_Permission::check('access CiviCRM')) { - $viewLinks = TRUE; - $onHover = ts('View Contact Summary for this Contact'); + $viewLinks = TRUE; + $onHover = ts('View Contact Summary for this Contact'); $onHoverAct = ts('View Activity Record'); } foreach ($rows as $rowNum => $row) { // if we have an activity type, format the View Activity link for use in various columns - if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) { + if ($viewLinks && + array_key_exists('civicrm_activity_activity_type_id', $row) + ) { // Check for target contact id(s) and use the first contact id in that list for view activity link if found, // else use source contact id if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) { @@ -762,7 +761,8 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}" 'reset=1&cid=' . $value, $this->_absoluteUrl ); - $link[] = "{$assigneeNames[$id]}"; + $link[] = "{$assigneeNames[$id]}"; } } $rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link); @@ -783,7 +783,8 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}" 'reset=1&cid=' . $value, $this->_absoluteUrl ); - $link[] = "{$targetNames[$id]}"; + $link[] = "{$targetNames[$id]}"; } } $rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link); @@ -835,7 +836,9 @@ GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}" } } - if (array_key_exists('civicrm_activity_activity_date_time', $row) && array_key_exists('civicrm_activity_status_id', $row)) { + if (array_key_exists('civicrm_activity_activity_date_time', $row) && + array_key_exists('civicrm_activity_status_id', $row) + ) { if (CRM_Utils_Date::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) && $activityStatus[$row['civicrm_activity_status_id']] != 'Completed' ) { diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index 038ae0ca1f..da49419620 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -145,8 +145,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { ), ), 'group_bys' => array( - 'activity_date_time' => - array( + 'activity_date_time' => array( 'title' => ts('Activity Date'), 'frequency' => TRUE, ), diff --git a/CRM/Report/Form/Campaign/SurveyDetails.php b/CRM/Report/Form/Campaign/SurveyDetails.php index f3091fb626..97a8a268ee 100644 --- a/CRM/Report/Form/Campaign/SurveyDetails.php +++ b/CRM/Report/Form/Campaign/SurveyDetails.php @@ -42,7 +42,13 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { protected $_summary = NULL; protected $_customGroupGroupBy = FALSE; - protected $_customGroupExtends = array('Contact', 'Individual', 'Household', 'Organization', 'Activity'); + protected $_customGroupExtends = array( + 'Contact', + 'Individual', + 'Household', + 'Organization', + 'Activity' + ); public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); private static $_surveyRespondentStatus; @@ -67,15 +73,16 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { self::$_surveyRespondentStatus[$statusId] = 'Interviewed'; } - $optionGroups = CRM_Campaign_BAO_Survey::getResultSets( 'name' ); + $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name'); $resultOptions = array(); - foreach ( $optionGroups as $gid => $name ) { - if ( $name ) { + foreach ($optionGroups as $gid => $name) { + if ($name) { $value = array(); $value = CRM_Core_OptionGroup::values($name); - if (!empty($value)) + if (!empty($value)) { $value = array_combine($value, $value); - $resultOptions = $resultOptions + $value; + } + $resultOptions = $resultOptions + $value; } } asort($resultOptions); @@ -84,55 +91,65 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { $allSurveyInterviewers = CRM_Campaign_BAO_Survey::getInterviewers(); $this->_columns = array( - 'civicrm_activity_contact' => - array( + 'civicrm_activity_contact' => array( 'dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array('contact_id' => array('title' => ts('Interviewer Name'))), 'filters' => array( - 'contact_id' => array('name' => 'contact_id', + 'contact_id' => array( + 'name' => 'contact_id', 'title' => ts('Interviewer Name'), 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => - CRM_Report_Form::OP_SELECT, + 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array( - '' => ts('- any interviewer -')) + $allSurveyInterviewers, - )), + '' => ts('- any interviewer -') + ) + $allSurveyInterviewers, + ) + ), 'grouping' => 'survey-interviewer-fields', ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array('id' => array('title' => ts('Contact ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE, ), - 'sort_name' => array('title' => ts('Respondent Name'), + 'sort_name' => array( + 'title' => ts('Respondent Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), ), - 'filters' => array('sort_name' => array('title' => ts('Respondent Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Respondent Name'), 'operator' => 'like', - )), + ) + ), 'grouping' => 'contact-fields', - 'order_bys' => array('sort_name' => array('title' => ts('Respondent Name'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Respondent Name'), 'required' => TRUE, - )), + ) + ), ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', 'fields' => array( - 'phone' => array('name' => 'phone', + 'phone' => array( + 'name' => 'phone', 'title' => ts('Phone'), - )), + ) + ), 'grouping' => 'location-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', 'fields' => array( - 'street_number' => array('name' => 'street_number', + 'street_number' => array( + 'name' => 'street_number', 'title' => ts('Street Number'), 'type' => 1, ), @@ -165,71 +182,71 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { 'title' => ts('Country'), ), ), - 'filters' => array('street_number' => array('title' => ts('Street Number'), + 'filters' => array( + 'street_number' => array( + 'title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number', ), - 'street_name' => array('title' => ts('Street Name'), + 'street_name' => array( + 'title' => ts('Street Name'), 'name' => 'street_name', 'operator' => 'like', ), - 'postal_code' => array('title' => ts('Postal Code'), + 'postal_code' => array( + 'title' => ts('Postal Code'), 'type' => 1, 'name' => 'postal_code', ), - 'city' => array('title' => ts('City'), + 'city' => array( + 'title' => ts('City'), 'operator' => 'like', 'name' => 'city', ), 'state_province_id' => array( 'name' => 'state_province_id', 'title' => ts('State/Province'), - 'operatorType' => - CRM_Report_Form::OP_MULTISELECT, - 'options' => - CRM_Core_PseudoConstant::stateProvince(), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_PseudoConstant::stateProvince(), ), 'country_id' => array( 'name' => 'country_id', 'title' => ts('Country'), - 'operatorType' => - CRM_Report_Form::OP_MULTISELECT, - 'options' => - CRM_Core_PseudoConstant::country(), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_PseudoConstant::country(), ), ), - 'order_bys' => - array('street_name' => array('title' => ts('Street Name')), - 'street_number_odd_even' => - array('title' => ts('Odd / Even Street Number'), - 'name' =>'street_number', - 'dbAlias' => 'address_civireport.street_number%2', - ), - 'street_number' => array('title' => 'Street Number'), - ), + 'order_bys' => array( + 'street_name' => array('title' => ts('Street Name')), + 'street_number_odd_even' => array( + 'title' => ts('Odd / Even Street Number'), + 'name' => 'street_number', + 'dbAlias' => 'address_civireport.street_number%2', + ), + 'street_number' => array('title' => 'Street Number'), + ), 'grouping' => 'location-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', 'fields' => array( - 'email' => array('name' => 'email', + 'email' => array( + 'name' => 'email', 'title' => ts('Email'), - )), + ) + ), 'grouping' => 'location-fields', ), - 'civicrm_activity' => - array( + 'civicrm_activity' => array( 'dao' => 'CRM_Activity_DAO_Activity', 'alias' => 'survey_activity', 'fields' => array( - 'survey_id' => array('name' => 'source_record_id', + 'survey_id' => array( + 'name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => - CRM_Report_Form::OP_MULTISELECT, - 'options' => - CRM_Campaign_BAO_Survey::getSurveys(), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Campaign_BAO_Survey::getSurveys(), ), 'survey_response' => array( 'name' => 'survey_response', @@ -247,12 +264,12 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { ), ), 'filters' => array( - 'survey_id' => array('name' => 'source_record_id', + 'survey_id' => array( + 'name' => 'source_record_id', 'title' => ts('Survey'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => - CRM_Campaign_BAO_Survey::getSurveys(), + 'options' => CRM_Campaign_BAO_Survey::getSurveys(), ), 'status_id' => array( 'name' => 'status_id', @@ -261,13 +278,12 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $responseStatus, ), - 'result' => - array( - 'title' => ts('Survey Result'), - 'type' => CRM_Utils_Type::T_STRING, - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $resultOptions, - ), + 'result' => array( + 'title' => ts('Survey Result'), + 'type' => CRM_Utils_Type::T_STRING, + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $resultOptions, + ), ), 'grouping' => 'survey-activity-fields', ), @@ -291,7 +307,9 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { continue; } foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName]) || CRM_Utils_Array::value('is_required', $field) + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) || + CRM_Utils_Array::value('is_required', $field) ) { $fieldsName = CRM_Utils_Array::value(1, explode('_', $tableName)); @@ -342,11 +360,19 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND {$this->_aliases['civicrm_phone']}.is_primary = 1\n"; } - if($this->_locationBasedPhoneField){ - foreach($this->_surveyResponseFields as $key => $value){ - if(substr($key,0,5) == 'phone' && !empty($value['location_type_id'])){ - $fName = str_replace('-','_',$key); - $this->_from .= "LEFT JOIN civicrm_phone ".$this->_aliases["civicrm_phone_{$fName}"]." ON {$this->_aliases['civicrm_contact']}.id = ".$this->_aliases["civicrm_phone_{$fName}"].".contact_id AND ".$this->_aliases["civicrm_phone_{$fName}"].".location_type_id = {$value['location_type_id']} AND ".$this->_aliases["civicrm_phone_{$fName}"].".phone_type_id = {$value['phone_type_id']}\n"; + if ($this->_locationBasedPhoneField) { + foreach ($this->_surveyResponseFields as $key => $value) { + if (substr($key, 0, 5) == 'phone' && !empty($value['location_type_id']) + ) { + $fName = str_replace('-', '_', $key); + $this->_from .= "LEFT JOIN civicrm_phone " . + $this->_aliases["civicrm_phone_{$fName}"] . + " ON {$this->_aliases['civicrm_contact']}.id = " . + $this->_aliases["civicrm_phone_{$fName}"] . ".contact_id AND " . + $this->_aliases["civicrm_phone_{$fName}"] . + ".location_type_id = {$value['location_type_id']} AND " . + $this->_aliases["civicrm_phone_{$fName}"] . + ".phone_type_id = {$value['phone_type_id']}\n"; } } } @@ -361,8 +387,8 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } @@ -388,7 +414,9 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { //apply survey activity types filter. $surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType(); if (!empty($surveyActivityTypes)) { - $clauses[] = "( {$this->_aliases['civicrm_activity']}.activity_type_id IN ( " . implode(' , ', array_keys($surveyActivityTypes)) . ' ) )'; + $clauses[] = + "( {$this->_aliases['civicrm_activity']}.activity_type_id IN ( " . + implode(' , ', array_keys($surveyActivityTypes)) . ' ) )'; } // always filter out deleted activities (so contacts that have been released @@ -429,38 +457,42 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { //we do need special formatted o/p only when we do have grouping $orderBys = CRM_Utils_Array::value('order_bys', $this->_params, array()); if (in_array($this->_outputMode, array( - 'print', 'pdf'))) { + 'print', + 'pdf' + ))) { $outPut = array(); $templateFile = parent::getTemplateFileName(); if (array_key_exists('street_name', $orderBys) || - array_key_exists('street_number', $orderBys) - ) { + array_key_exists('street_number', $orderBys) + ) { $orderByStreetName = CRM_Utils_Array::value('street_name', $orderBys); $orderByStreetNum = CRM_Utils_Array::value('street_number', $orderBys); - $pageCnt = 0; - $dataPerPage = array(); + $pageCnt = 0; + $dataPerPage = array(); $lastStreetName = $lastStreetNum = NULL; foreach ($rows as $row) { //do we need to take new page. if ($orderByStreetName && - ($lastStreetName != CRM_Utils_Array::value('civicrm_address_street_name', $row)) - ) { + ($lastStreetName != + CRM_Utils_Array::value('civicrm_address_street_name', $row)) + ) { $pageCnt++; } elseif ($orderByStreetNum && - ($lastStreetNum != - CRM_Utils_Array::value('civicrm_address_street_number', $row) % 2 - ) - ) { + ($lastStreetNum != + CRM_Utils_Array::value('civicrm_address_street_number', $row) % 2 + ) + ) { $pageCnt++; } //get the data per page. $dataPerPage[$pageCnt][] = $row; $lastStreetName = CRM_Utils_Array::value('civicrm_address_street_name', $row); - $lastStreetNum = CRM_Utils_Array::value('civicrm_address_street_number', $row) % 2; + $lastStreetNum = + CRM_Utils_Array::value('civicrm_address_street_number', $row) % 2; } foreach ($dataPerPage as $page) { @@ -481,10 +513,12 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { $coverSheet = $this->_surveyCoverSheet(); $footerImage = preg_replace('/<\/html>|<\/body>|<\/div>/i', '', $footer); - $outPut = $header . $coverSheet . "
" . implode($footerImage . - "
", - $outPut - ) . $footer; + $outPut = $header . $coverSheet . + "
" . + implode($footerImage . + "
", + $outPut + ) . $footer; if ($this->_outputMode == 'print') { echo $outPut; @@ -650,7 +684,8 @@ INNER JOIN civicrm_option_value val ON ( val.option_group_id = survey.result_id */ private function _formatSurveyResult(&$rows) { $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); - if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['result']) || + if (CRM_Utils_System::isNull($surveyIds) || + empty($this->_params['fields']['result']) || !in_array($this->_outputMode, array('print', 'pdf')) ) { return; @@ -700,7 +735,9 @@ INNER JOIN civicrm_survey survey ON ( survey.result_id = grp.id ) */ private function _formatSurveyResponseData(&$rows) { $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); - if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['survey_response'])) { + if (CRM_Utils_System::isNull($surveyIds) || + empty($this->_params['fields']['survey_response']) + ) { return; } @@ -759,8 +796,8 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) Order By ov.weight'; $responseFields = array(); - $fieldValueMap = array(); - $properties = array( + $fieldValueMap = array(); + $properties = array( 'id', 'data_type', 'html_type', @@ -770,7 +807,8 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) $responseField = CRM_Core_DAO::executeQuery($query); while ($responseField->fetch()) { - $reponseFldName = $responseField->table_name . '_custom_' . $responseField->id; + $reponseFldName = $responseField->table_name . '_custom_' . + $responseField->id; foreach ($properties as $prop) { $responseFields[$reponseFldName][$prop] = $responseField->$prop; } @@ -778,7 +816,9 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) //show value for print and pdf. $value = $responseField->label; if (in_array($this->_outputMode, array( - 'print', 'pdf'))) { + 'print', + 'pdf' + ))) { $value = $responseField->value; } $fieldValueMap[$responseField->option_group_id][$responseField->value] = $value; @@ -802,8 +842,8 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) in_array($this->_outputMode, array('print', 'pdf')) ) { $optGrpId = CRM_Utils_Array::value('option_group_id', $responseFields[$name]); - $options = CRM_Utils_Array::value($optGrpId, $fieldValueMap, array()); - $value = implode(' | ', array_keys($options)); + $options = CRM_Utils_Array::value($optGrpId, $fieldValueMap, array()); + $value = implode(' | ', array_keys($options)); } else { $value = $this->formatCustomValues($value, @@ -813,14 +853,17 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) } } - if (!$hasData) - break; + if (!$hasData) { + break; + } } } private function _addSurveyResponseColumns() { $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); - if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['survey_response'])) { + if (CRM_Utils_System::isNull($surveyIds) || + empty($this->_params['fields']['survey_response']) + ) { return; } @@ -829,20 +872,23 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) $responseFields += CRM_Campaign_BAO_Survey::getSurveyResponseFields($surveyId); $this->_surveyResponseFields = $responseFields; } - foreach($responseFields as $key => $value){ - if(substr($key,0,5) == 'phone' && !empty($value['location_type_id'])){ - $fName = str_replace('-','_',$key); + foreach ($responseFields as $key => $value) { + if (substr($key, 0, 5) == 'phone' && !empty($value['location_type_id'])) { + $fName = str_replace('-', '_', $key); $this->_columns["civicrm_{$fName}"] = - array( 'dao' => 'CRM_Core_DAO_Phone', - 'alias' => "phone_civireport_{$fName}", - 'fields' => - array( $fName => array_merge($value, array( 'is_required' => '1', 'alias' => "phone_civireport_{$fName}", - 'dbAlias' => "phone_civireport_{$fName}.phone", - 'no_display' => TRUE, - ) - ), - ), - ); + array( + 'dao' => 'CRM_Core_DAO_Phone', + 'alias' => "phone_civireport_{$fName}", + 'fields' => array( + $fName => array_merge($value, array( + 'is_required' => '1', + 'alias' => "phone_civireport_{$fName}", + 'dbAlias' => "phone_civireport_{$fName}.phone", + 'no_display' => TRUE, + ) + ), + ), + ); $this->_aliases["civicrm_phone_{$fName}"] = $this->_columns["civicrm_{$fName}"]['alias']; $this->_locationBasedPhoneField = TRUE; } @@ -869,7 +915,8 @@ INNER JOIN civicrm_custom_group cg ON ( cg.id = cf.custom_group_id ) cf.option_group_id FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON ( cg.id = cf.custom_group_id ) - WHERE cf.id IN ( ' . implode(' , ', $responseFieldIds) . ' ) ORDER BY cf.weight'; + WHERE cf.id IN ( ' . implode(' , ', $responseFieldIds) . + ' ) ORDER BY cf.weight'; $response = CRM_Core_DAO::executeQuery($query); $fildCnt = 1; while ($response->fetch()) { @@ -896,7 +943,9 @@ INNER JOIN civicrm_custom_field cf ON ( cg.id = cf.custom_group_id ) $title = $responseFields[$fieldName]['title']; if (in_array($this->_outputMode, array( - 'print', 'pdf'))) { + 'print', + 'pdf' + ))) { $title = 'Q' . $fildCnt++; } @@ -912,8 +961,11 @@ INNER JOIN civicrm_custom_field cf ON ( cg.id = cf.custom_group_id ) 'dataType' => $response->data_type, 'htmlType' => $response->html_type, 'required' => TRUE, - 'alias' => ($response->data_type == 'ContactReference') ? $this->_columns[$resTable]['alias'] . '_contact' : $this->_columns[$resTable]['alias'], - 'dbAlias' => $this->_columns[$resTable]['alias'] . '.' . $response->column_name, + 'alias' => ($response->data_type == 'ContactReference') ? + $this->_columns[$resTable]['alias'] . + '_contact' : $this->_columns[$resTable]['alias'], + 'dbAlias' => $this->_columns[$resTable]['alias'] . '.' . + $response->column_name, 'no_display' => TRUE, 'isSurveyResponseField' => TRUE, ); diff --git a/CRM/Report/Form/Case/Demographics.php b/CRM/Report/Form/Case/Demographics.php index 6ad964019e..2a5d17b289 100644 --- a/CRM/Report/Form/Case/Demographics.php +++ b/CRM/Report/Form/Case/Demographics.php @@ -49,142 +49,136 @@ class CRM_Report_Form_Case_Demographics extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), - 'gender_id' => - array('title' => ts('Gender'), + 'gender_id' => array( + 'title' => ts('Gender'), 'default' => TRUE, ), - 'birth_date' => - array('title' => ts('Birthdate'), + 'birth_date' => array( + 'title' => ts('Birthdate'), 'default' => FALSE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'filters' => - array( + 'filters' => array( 'sort_name' => array( 'title' => ts('Contact Name'), 'operatorType' => CRM_Report_Form::OP_STRING, ), - 'contact_type' => - array('title' => ts('Contact Type'), + 'contact_type' => array( + 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('-select-'), + 'options' => array( + '' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household'), ), 'default' => 'Individual', ), - 'id' => - array('title' => ts('Contact ID'), + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => - array( - 'street_address' => - array('default' => FALSE), - 'city' => - array('default' => TRUE), + 'fields' => array( + 'street_address' => array('default' => FALSE), + 'city' => array('default' => TRUE), 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), 'default' => FALSE, ), ), /* - 'filters' => - array( - 'country_id' => - array( 'title' => ts( 'Country' ), + 'filters' => array( + 'country_id' => array( 'title' => ts( 'Country' ), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country( ), ), - 'state_province_id' => - array( 'title' => ts( 'State/Province' ), + 'state_province_id' => array( 'title' => ts( 'State/Province' ), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince( ), ), ), */ ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array('phone' => NULL), + 'fields' => array('phone' => NULL), 'grouping' => 'contact-fields', ), - 'civicrm_activity' => - array( + 'civicrm_activity' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array('id' => array('title' => ts('Activity ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE, ), ), ), - 'civicrm_case' => - array( + 'civicrm_case' => array( 'dao' => 'CRM_Case_DAO_Case', - 'fields' => - array('id' => array('title' => ts('Case ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Case ID'), 'required' => TRUE, ), - 'start_date' => array('title' => ts('Case Start'), + 'start_date' => array( + 'title' => ts('Case Start'), 'required' => TRUE, ), - 'end_date' => array('title' => ts('Case End'), + 'end_date' => array( + 'title' => ts('Case End'), 'required' => TRUE, ), ), - 'filters' => - array( - 'case_id_filter' => array('name' => 'id', + 'filters' => array( + 'case_id_filter' => array( + 'name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), + 'options' => array( + 1 => ts('Exclude non-case'), + 2 => ts('Exclude cases'), + 3 => ts('Include Both') + ), 'default' => 3, ), - 'start_date' => array('title' => ts('Case Start'), + 'start_date' => array( + 'title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'end_date' => array('title' => ts('Case End'), + 'end_date' => array( + 'title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE, ), ), @@ -197,8 +191,8 @@ class CRM_Report_Form_Case_Demographics extends CRM_Report_Form { $open_case_val = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); $crmDAO = &CRM_Core_DAO::executeQuery("SELECT cg.table_name, cg.extends AS ext, cf.label, cf.column_name FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='$open_case_val') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name"); - $curTable = ''; - $curExt = ''; + $curTable = ''; + $curExt = ''; $curFields = array(); while ($crmDAO->fetch()) { if ($curTable == '') { @@ -212,8 +206,8 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu 'fields' => $curFields, 'ext' => $curExt, ); - $curTable = $crmDAO->table_name; - $curExt = $crmDAO->ext; + $curTable = $crmDAO->table_name; + $curExt = $crmDAO->ext; $curFields = array(); } @@ -243,7 +237,9 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -287,9 +283,12 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu "; foreach ($this->_columns as $t => $c) { - if (substr($t, 0, 13) == 'civicrm_value' || substr($t, 0, 12) == 'custom_value') { + if (substr($t, 0, 13) == 'civicrm_value' || + substr($t, 0, 12) == 'custom_value' + ) { $this->_from .= " LEFT JOIN $t {$this->_aliases[$t]} ON {$this->_aliases[$t]}.entity_id = "; - $this->_from .= ($c['ext'] == 'Activity') ? "{$this->_aliases['civicrm_activity']}.id" : "{$this->_aliases['civicrm_contact']}.id"; + $this->_from .= ($c['ext'] == + 'Activity') ? "{$this->_aliases['civicrm_activity']}.id" : "{$this->_aliases['civicrm_contact']}.id"; } } @@ -317,8 +316,8 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu $clause = NULL; if ($field['operatorType'] & CRM_Report_Form::OP_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, CRM_Utils_Type::T_DATE); } @@ -426,7 +425,9 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu // handle custom fields foreach ($row as $k => $r) { - if (substr($k, 0, 13) == 'civicrm_value' || substr($k, 0, 12) == 'custom_value') { + if (substr($k, 0, 13) == 'civicrm_value' || + substr($k, 0, 12) == 'custom_value' + ) { if ($r || $r == '0') { if ($newval = $this->getCustomFieldLabel($k, $r)) { $rows[$rowNum][$k] = $newval; @@ -457,7 +458,8 @@ SELECT v.label INNER JOIN civicrm_option_group g ON cf.option_group_id = g.id INNER JOIN civicrm_option_value v ON g.id = v.option_group_id WHERE CONCAT(cg.table_name, '_', cf.column_name) = %1 AND v.value = %2"; - $params = array(1 => array($fname, 'String'), + $params = array( + 1 => array($fname, 'String'), 2 => array($val, 'String'), ); return CRM_Core_DAO::singleValueQuery($query, $params); diff --git a/CRM/Report/Form/Case/Detail.php b/CRM/Report/Form/Case/Detail.php index 7c4c343334..0d88234558 100644 --- a/CRM/Report/Form/Case/Detail.php +++ b/CRM/Report/Form/Case/Detail.php @@ -51,8 +51,7 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { protected $_includeCaseDetailExtra = FALSE; - protected $_caseDetailExtra = array( - ); + protected $_caseDetailExtra = array(); /** * @@ -62,13 +61,17 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { */ function __construct() { $this->case_statuses = CRM_Core_OptionGroup::values('case_status'); - $this->case_types = CRM_Case_PseudoConstant::caseType(); - $rels = CRM_Core_PseudoConstant::relationshipType(); + $this->case_types = CRM_Case_PseudoConstant::caseType(); + $rels = CRM_Core_PseudoConstant::relationshipType(); foreach ($rels as $relid => $v) { $this->rel_types[$relid] = $v['label_b_a']; } - $this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes')); + $this->deleted_labels = array( + '' => ts('- select -'), + 0 => ts('No'), + 1 => ts('Yes') + ); $this->caseActivityTypes = array(); foreach (CRM_Case_PseudoConstant::caseActivityType() as $typeDetail) { @@ -76,50 +79,57 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_case' => - array( + 'civicrm_case' => array( 'dao' => 'CRM_Case_DAO_Case', - 'fields' => - array( - 'id' => array('title' => ts('Case ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Case ID'), 'no_display' => TRUE, 'required' => TRUE, ), - 'subject' => array('title' => ts('Subject'), + 'subject' => array( + 'title' => ts('Subject'), 'required' => TRUE, ), - 'start_date' => array('title' => ts('Start Date'), + 'start_date' => array( + 'title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE, ), - 'end_date' => array('title' => ts('End Date'), + 'end_date' => array( + 'title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE, ), 'status_id' => array('title' => ts('Case Status')), 'case_type_id' => array('title' => ts('Case Type')), - 'is_deleted' => array('title' => ts('Deleted?'), + 'is_deleted' => array( + 'title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT, ), ), - 'filters' => - array( - 'start_date' => array('title' => ts('Start Date'), + 'filters' => array( + 'start_date' => array( + 'title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'end_date' => array('title' => ts('End Date'), + 'end_date' => array( + 'title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'status_id' => array('title' => ts('Case Status'), + 'status_id' => array( + 'title' => ts('Case Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses, ), - 'case_type_id' => array('title' => ts('Case Type'), + 'case_type_id' => array( + 'title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types, ), - 'is_deleted' => array('title' => ts('Deleted?'), + 'is_deleted' => array( + 'title' => ts('Deleted?'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, @@ -127,11 +137,9 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { ), ), ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( + 'fields' => array( 'client_sort_name' => array( 'name' => 'sort_name', 'title' => ts('Client Name'), @@ -142,24 +150,20 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { 'required' => TRUE, ), ), - 'filters' => - array( + 'filters' => array( 'sort_name' => array('title' => ts('Client Name')), ), ), - 'civicrm_relationship' => - array( + 'civicrm_relationship' => array( 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => - array( - 'case_role' => array('name' => 'relationship_type_id', + 'fields' => array( + 'case_role' => array( + 'name' => 'relationship_type_id', 'title' => ts('Case Role(s)'), ), ), - 'filters' => - array( - 'case_role' => - array( + 'filters' => array( + 'case_role' => array( 'name' => 'relationship_type_id', 'title' => ts('Case Role(s)'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -167,60 +171,54 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { ), ), ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array('email' => array('title' => ts('Email'), + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, - 'state_province_id' => array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), 'country_id' => array('title' => ts('Country')), ), 'grouping' => 'contact-fields', - 'filters' => - array( - 'country_id' => - array('title' => ts('Country'), + 'filters' => array( + 'country_id' => array( + 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), ), ), - 'civicrm_worldregion' => - array( + 'civicrm_worldregion' => array( 'dao' => 'CRM_Core_DAO_Worldregion', - 'filters' => - array( + 'filters' => array( 'worldregion_id' => array( 'name' => 'id', 'title' => ts('World Region'), @@ -230,17 +228,13 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { ), ), ), - 'civicrm_country' => - array( + 'civicrm_country' => array( 'dao' => 'CRM_Core_DAO_Country', ), - 'civicrm_activity_last' => - array( + 'civicrm_activity_last' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'filters' => - array( - 'last_activity_date_time' => - array( + 'filters' => array( + 'last_activity_date_time' => array( 'name' => 'activity_date_time', 'title' => ts('Last Action Date'), 'operatorType' => CRM_Report_Form::OP_DATE, @@ -248,18 +242,14 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { ), 'alias' => 'civireport_activity_last', ), - 'civicrm_activity_last_completed' => - array( + 'civicrm_activity_last_completed' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array( - 'last_completed_activity_subject' => - array( + 'fields' => array( + 'last_completed_activity_subject' => array( 'name' => 'subject', 'title' => ts('Subject of the last completed activity in the case'), ), - 'last_completed_activity_type' => - array( + 'last_completed_activity_type' => array( 'name' => 'activity_type_id', 'title' => ts('Activity type of the last completed activity'), ), @@ -268,8 +258,8 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { ); $this->_options = array( - 'my_cases' => - array('title' => ts('My Cases'), + 'my_cases' => array( + 'title' => ts('My Cases'), 'type' => 'checkbox', ), ); @@ -289,11 +279,14 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { $elements = array(); $elements[] = &$this->createElement('select', 'case_activity_all_dates', NULL, array( - '' => ts('- select -')) + $this->caseActivityTypes + '' => ts('- select -') + ) + $this->caseActivityTypes ); $this->addGroup($elements, 'case_detail_extra'); - $this->_caseDetailExtra = array('case_activity_all_dates' => array('title' => ts('List of all dates of activities of Type'), + $this->_caseDetailExtra = array( + 'case_activity_all_dates' => array( + 'title' => ts('List of all dates of activities of Type'), 'name' => 'activity_date_time', ), ); @@ -310,7 +303,9 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -408,18 +403,21 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); - if ($fieldName == 'case_type_id' && !empty($this->_params['case_type_id_value'])) { + if ($fieldName == 'case_type_id' && + !empty($this->_params['case_type_id_value']) + ) { foreach ($this->_params['case_type_id_value'] as $key => $value) { if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) === FALSE) { - $value = CRM_Core_DAO::VALUE_SEPARATOR . $value . CRM_Core_DAO::VALUE_SEPARATOR; + $value = CRM_Core_DAO::VALUE_SEPARATOR . $value . + CRM_Core_DAO::VALUE_SEPARATOR; $this->_params['case_type_id_value'][$key] = "'{$value}'"; } @@ -447,8 +445,8 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { } if (isset($this->_params['options']['my_cases'])) { - $session = CRM_Core_Session::singleton(); - $userID = $session->get('userID'); + $session = CRM_Core_Session::singleton(); + $userID = $session->get('userID'); $clauses[] = "{$this->_aliases['civicrm_contact']}.id = {$userID}"; } @@ -472,17 +470,18 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { function statistics(&$rows) { $statistics = parent::statistics($rows); - $select = "select COUNT( DISTINCT( {$this->_aliases['civicrm_address']}.country_id))"; - $sql = "{$select} {$this->_from} {$this->_where}"; + $select = "select COUNT( DISTINCT( {$this->_aliases['civicrm_address']}.country_id))"; + $sql = "{$select} {$this->_from} {$this->_where}"; $countryCount = CRM_Core_DAO::singleValueQuery($sql); //CaseType statistics if (array_key_exists('filters', $statistics)) { foreach ($statistics['filters'] as $id => $value) { if ($value['title'] == 'Case Type') { - $statistics['filters'][$id]['value'] = 'Is ' . $this->case_types[substr($statistics['filters'][$id] - ['value'], -3, -2 - )]; + $statistics['filters'][$id]['value'] = 'Is ' . + $this->case_types[substr($statistics['filters'][$id] + ['value'], -3, -2 + )]; } } } @@ -517,7 +516,8 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { LEFT JOIN civicrm_activity civireport_activity_all_{$activityType} ON ( civireport_activity_all_{$activityType}.id = civireport_case_activity_all_{$activityType}.activity_id AND civireport_activity_all_{$activityType}.activity_type_id = {$activityType})"; $this->_columnHeaders['case_activity_all_dates'] = array( - 'title' => $this->_caseDetailExtra['case_activity_all_dates']['title'] . ": {$this->caseActivityTypes[$activityType]}", + 'title' => $this->_caseDetailExtra['case_activity_all_dates']['title'] . + ": {$this->caseActivityTypes[$activityType]}", 'type' => CRM_Utils_Array::value('type', $this->_caseDetailExtra['case_activity_all_dates']), ); } @@ -548,7 +548,9 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { } function checkEnabledFields() { - if (isset($this->_params['worldregion_id_value']) && !empty($this->_params['worldregion_id_value'])) { + if (isset($this->_params['worldregion_id_value']) && + !empty($this->_params['worldregion_id_value']) + ) { $this->_addressField = TRUE; $this->_worldRegionField = TRUE; } @@ -559,7 +561,8 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { $this->_relField = TRUE; } - if (!empty($this->_params['activity_date_time_relative']) || !empty($this->_params['activity_date_time_from']) || + if (!empty($this->_params['activity_date_time_relative']) || + !empty($this->_params['activity_date_time_from']) || CRM_Utils_Array::value('activity_date_time_to', $this->_params) ) { $this->_activityLast = TRUE; @@ -627,7 +630,9 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form { } $entryFound = TRUE; } - if (array_key_exists('civicrm_activity_last_completed_last_completed_activity_subject', $row) && empty($row['civicrm_activity_last_completed_last_completed_activity_subject'])) { + if (array_key_exists('civicrm_activity_last_completed_last_completed_activity_subject', $row) && + empty($row['civicrm_activity_last_completed_last_completed_activity_subject']) + ) { $rows[$rowNum]['civicrm_activity_last_completed_last_completed_activity_subject'] = ts('(no subject)'); $entryFound = TRUE; } diff --git a/CRM/Report/Form/Case/Summary.php b/CRM/Report/Form/Case/Summary.php index f722db28a4..fbfee3c541 100644 --- a/CRM/Report/Form/Case/Summary.php +++ b/CRM/Report/Form/Case/Summary.php @@ -46,85 +46,96 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { * */ function __construct() { - $this->case_types = CRM_Case_PseudoConstant::caseType(); + $this->case_types = CRM_Case_PseudoConstant::caseType(); $this->case_statuses = CRM_Core_OptionGroup::values('case_status'); - $rels = CRM_Core_PseudoConstant::relationshipType(); + $rels = CRM_Core_PseudoConstant::relationshipType(); foreach ($rels as $relid => $v) { $this->rel_types[$relid] = $v['label_b_a']; } - $this->deleted_labels = array('' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes')); + $this->deleted_labels = array( + '' => ts('- select -'), + 0 => ts('No'), + 1 => ts('Yes') + ); $this->_columns = array( - 'civicrm_c2' => - array( + 'civicrm_c2' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'client_name' => - array( + 'fields' => array( + 'client_name' => array( 'name' => 'sort_name', 'title' => ts('Client'), 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), ), - 'civicrm_case' => - array( + 'civicrm_case' => array( 'dao' => 'CRM_Case_DAO_Case', - 'fields' => - array( - 'id' => - array('title' => ts('Case ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Case ID'), 'required' => TRUE, ), 'subject' => array( - 'title' => ts('Case Subject'), 'default' => TRUE, + 'title' => ts('Case Subject'), + 'default' => TRUE, ), 'status_id' => array( - 'title' => ts('Status'), 'default' => TRUE, + 'title' => ts('Status'), + 'default' => TRUE, ), 'case_type_id' => array( - 'title' => ts('Case Type'), 'default' => TRUE, + 'title' => ts('Case Type'), + 'default' => TRUE, ), 'start_date' => array( - 'title' => ts('Start Date'), 'default' => TRUE, + 'title' => ts('Start Date'), + 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE, ), 'end_date' => array( - 'title' => ts('End Date'), 'default' => TRUE, + 'title' => ts('End Date'), + 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE, ), 'duration' => array( - 'title' => ts('Duration (Days)'), 'default' => FALSE, + 'title' => ts('Duration (Days)'), + 'default' => FALSE, ), 'is_deleted' => array( - 'title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT, + 'title' => ts('Deleted?'), + 'default' => FALSE, + 'type' => CRM_Utils_Type::T_INT, ), ), - 'filters' => - array('start_date' => array('title' => ts('Start Date'), + 'filters' => array( + 'start_date' => array( + 'title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'end_date' => array('title' => ts('End Date'), + 'end_date' => array( + 'title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'case_type_id' => array('title' => ts('Case Type'), + 'case_type_id' => array( + 'title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types, ), - 'status_id' => array('title' => ts('Status'), + 'status_id' => array( + 'title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses, ), - 'is_deleted' => array('title' => ts('Deleted?'), + 'is_deleted' => array( + 'title' => ts('Deleted?'), 'type' => CRM_Report_Form::OP_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, @@ -132,44 +143,40 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { ), ), ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Staff Member'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Staff Member'), 'default' => TRUE, ), ), - 'filters' => - array('sort_name' => array('title' => ts('Staff Member'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Staff Member'), ), ), ), - 'civicrm_relationship' => - array( + 'civicrm_relationship' => array( 'dao' => 'CRM_Contact_DAO_Relationship', - 'filters' => - array('relationship_type_id' => array('title' => ts('Staff Relationship'), + 'filters' => array( + 'relationship_type_id' => array( + 'title' => ts('Staff Relationship'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types, ), ), ), - 'civicrm_relationship_type' => - array( + 'civicrm_relationship_type' => array( 'dao' => 'CRM_Contact_DAO_RelationshipType', - 'fields' => - array( - 'label_b_a' => - array( - 'title' => ts('Relationship'), 'default' => TRUE, + 'fields' => array( + 'label_b_a' => array( + 'title' => ts('Relationship'), + 'default' => TRUE, ), ), ), - 'civicrm_case_contact' => - array( + 'civicrm_case_contact' => array( 'dao' => 'CRM_Case_DAO_CaseContact', ), ); @@ -187,7 +194,9 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_relationship_type') { $this->_relField = TRUE; @@ -218,10 +227,17 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { */ static function formRule($fields, $files, $self) { $errors = $grouping = array(); - if (empty($fields['relationship_type_id_value']) && (array_key_exists('sort_name', $fields['fields']) || array_key_exists('label_b_a', $fields['fields']))) { + if (empty($fields['relationship_type_id_value']) && + (array_key_exists('sort_name', $fields['fields']) || + array_key_exists('label_b_a', $fields['fields'])) + ) { $errors['fields'] = ts('Either filter on at least one relationship type, or de-select Staff Member and Relationship from the list of fields.'); } - if ((!empty($fields['relationship_type_id_value']) || !empty($fields['sort_name_value'])) && (!array_key_exists('sort_name', $fields['fields']) || !array_key_exists('label_b_a', $fields['fields']))) { + if ((!empty($fields['relationship_type_id_value']) || + !empty($fields['sort_name_value'])) && + (!array_key_exists('sort_name', $fields['fields']) || + !array_key_exists('label_b_a', $fields['fields'])) + ) { $errors['fields'] = ts('To filter on Staff Member or Relationship, please also select Staff Member and Relationship from the list of fields.'); } return $errors; @@ -229,10 +245,10 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { function from() { - $cc = $this->_aliases['civicrm_case']; - $c = $this->_aliases['civicrm_contact']; - $c2 = $this->_aliases['civicrm_c2']; - $cr = $this->_aliases['civicrm_relationship']; + $cc = $this->_aliases['civicrm_case']; + $c = $this->_aliases['civicrm_contact']; + $c2 = $this->_aliases['civicrm_c2']; + $cr = $this->_aliases['civicrm_relationship']; $crt = $this->_aliases['civicrm_relationship_type']; $ccc = $this->_aliases['civicrm_case_contact']; @@ -262,10 +278,12 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - if (CRM_Utils_Array::value("operatorType", $field) & CRM_Report_Form::OP_DATE) { + if (CRM_Utils_Array::value("operatorType", $field) & + CRM_Report_Form::OP_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, CRM_Utils_Array::value('type', $field) @@ -277,7 +295,8 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id if ($fieldName == 'case_type_id') { $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); if (!empty($value)) { - $clause = "( {$field['dbAlias']} REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', $value) . "[[:>:]]' )"; + $clause = "( {$field['dbAlias']} REGEXP '[[:<:]]" . + implode('[[:>:]]|[[:<:]]', $value) . "[[:>:]]' )"; } $op = NULL; } @@ -338,10 +357,12 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id } } - if (array_key_exists('civicrm_case_case_type_id', $row) && !empty($rows[$rowNum]['civicrm_case_case_type_id'])) { - $value = $row['civicrm_case_case_type_id']; + if (array_key_exists('civicrm_case_case_type_id', $row) && + !empty($rows[$rowNum]['civicrm_case_case_type_id']) + ) { + $value = $row['civicrm_case_case_type_id']; $typeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $value = array(); + $value = array(); foreach ($typeIds as $typeId) { if ($typeId) { $value[$typeId] = $this->case_types[$typeId]; @@ -352,18 +373,24 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id } // convert Case ID and Subject to links to Manage Case - if (array_key_exists('civicrm_case_id', $row) && !empty($rows[$rowNum]['civicrm_c2_id'])) { + if (array_key_exists('civicrm_case_id', $row) && + !empty($rows[$rowNum]['civicrm_c2_id']) + ) { $url = CRM_Utils_System::url("civicrm/contact/view/case", - 'reset=1&action=view&cid=' . $row['civicrm_c2_id'] . '&id=' . $row['civicrm_case_id'], + 'reset=1&action=view&cid=' . $row['civicrm_c2_id'] . '&id=' . + $row['civicrm_case_id'], $this->_absoluteUrl ); $rows[$rowNum]['civicrm_case_id_link'] = $url; $rows[$rowNum]['civicrm_case_id_hover'] = ts("Manage Case"); $entryFound = TRUE; } - if (array_key_exists('civicrm_case_subject', $row) && !empty($rows[$rowNum]['civicrm_c2_id'])) { + if (array_key_exists('civicrm_case_subject', $row) && + !empty($rows[$rowNum]['civicrm_c2_id']) + ) { $url = CRM_Utils_System::url("civicrm/contact/view/case", - 'reset=1&action=view&cid=' . $row['civicrm_c2_id'] . '&id=' . $row['civicrm_case_id'], + 'reset=1&action=view&cid=' . $row['civicrm_c2_id'] . '&id=' . + $row['civicrm_case_id'], $this->_absoluteUrl ); $rows[$rowNum]['civicrm_case_subject_link'] = $url; diff --git a/CRM/Report/Form/Case/TimeSpent.php b/CRM/Report/Form/Case/TimeSpent.php index 328f1cac07..3c5d318aec 100644 --- a/CRM/Report/Form/Case/TimeSpent.php +++ b/CRM/Report/Form/Case/TimeSpent.php @@ -47,126 +47,115 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { $this->activityStatuses = CRM_Core_PseudoConstant::activityStatus(); $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'id' => - array('title' => ts('Contact ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE, ), - 'sort_name' => - array('title' => ts('Contact Name'), + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, ), ), ), - 'civicrm_activity' => - array( + 'civicrm_activity' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array( - 'activity_type_id' => - array('title' => ts('Activity Type'), + 'fields' => array( + 'activity_type_id' => array( + 'title' => ts('Activity Type'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, ), - 'activity_date_time' => - array('title' => ts('Activity Date'), + 'activity_date_time' => array( + 'title' => ts('Activity Date'), 'default' => TRUE, ), - 'status_id' => - array('title' => ts('Activity Status'), + 'status_id' => array( + 'title' => ts('Activity Status'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_STRING, ), - 'id' => - array('title' => ts('Activity ID'), + 'id' => array( + 'title' => ts('Activity ID'), 'default' => TRUE, ), - 'duration' => - array('title' => ts('Duration'), + 'duration' => array( + 'title' => ts('Duration'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_INT, ), - 'subject' => - array('title' => ts('Activity Subject'), + 'subject' => array( + 'title' => ts('Activity Subject'), 'default' => FALSE, ), ), - 'filters' => - array( - 'activity_date_time' => - //'default' => 'this.month', - array( - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'subject' => - array('title' => ts('Activity Subject'), + 'filters' => array( + 'activity_date_time' => //'default' => 'this.month', + array( + 'operatorType' => CRM_Report_Form::OP_DATE, + ), + 'subject' => array( + 'title' => ts('Activity Subject'), 'operator' => 'like', ), - 'activity_type_id' => - array('title' => ts('Activity Type'), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes, ), - 'status_id' => - array('title' => ts('Activity Status'), + 'status_id' => array( + 'title' => ts('Activity Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityStatuses, ), ), ), - 'civicrm_activity_source' => - array( - 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - 'contact_id' => - array( - 'title' => ts('Contact ID'), - 'default' => TRUE, - 'no_display' => TRUE, - ), + 'civicrm_activity_source' => array( + 'dao' => 'CRM_Activity_DAO_ActivityContact', + 'fields' => array( + 'contact_id' => array( + 'title' => ts('Contact ID'), + 'default' => TRUE, + 'no_display' => TRUE, ), - 'group_bys' => - array( - 'contact_id' => - array('title' => ts('Totals Only'), - 'default' => TRUE, - ), + ), + 'group_bys' => array( + 'contact_id' => array( + 'title' => ts('Totals Only'), + 'default' => TRUE, ), + ), 'grouping' => 'activity-fields', ), - 'civicrm_case_activity' => - array( + 'civicrm_case_activity' => array( 'dao' => 'CRM_Case_DAO_CaseActivity', - 'fields' => - array( - 'case_id' => - array('title' => ts('Case ID'), + 'fields' => array( + 'case_id' => array( + 'title' => ts('Case ID'), 'default' => FALSE, ), ), - 'filters' => - array( - 'case_id_filter' => - array( + 'filters' => array( + 'case_id_filter' => array( 'name' => 'case_id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), + 'options' => array( + 1 => ts('Exclude non-case'), + 2 => ts('Exclude cases'), + 3 => ts('Include Both') + ), 'default' => 3, ), ), @@ -187,7 +176,9 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { if (!empty($field['required']) || - (!empty($this->_params['fields'][$fieldName]) && ((!$this->has_grouping) || !in_array($fieldName, array('case_id', 'subject', 'status_id'))) + (!empty($this->_params['fields'][$fieldName]) && + ((!$this->has_grouping) || + !in_array($fieldName, array('case_id', 'subject', 'status_id'))) ) ) { @@ -206,7 +197,9 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { $select[] = "EXTRACT(YEAR_MONTH FROM {$field['dbAlias']}) AS {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = ts('Month/Year'); } - elseif ($tableName == 'civicrm_activity' && $fieldName == 'id' && $this->has_grouping) { + elseif ($tableName == 'civicrm_activity' && $fieldName == 'id' && + $this->has_grouping + ) { $select[] = "COUNT({$field['dbAlias']}) AS {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = ts('# Activities'); } @@ -246,8 +239,8 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } @@ -320,7 +313,9 @@ GROUP BY {$this->_aliases['civicrm_contact']}.id, static function formRule($fields, $files, $self) { $errors = array(); if (!empty($fields['group_bys']) && - (!array_key_exists('id', $fields['fields']) || !array_key_exists('activity_date_time', $fields['fields']) || !array_key_exists('duration', $fields['fields'])) + (!array_key_exists('id', $fields['fields']) || + !array_key_exists('activity_date_time', $fields['fields']) || + !array_key_exists('duration', $fields['fields'])) ) { $errors['fields'] = ts('To view totals please select all of activity id, date and duration.'); } diff --git a/CRM/Report/Form/Contact/CurrentEmployer.php b/CRM/Report/Form/Contact/CurrentEmployer.php index 29f013c686..1b389e6e94 100644 --- a/CRM/Report/Form/Contact/CurrentEmployer.php +++ b/CRM/Report/Form/Contact/CurrentEmployer.php @@ -38,7 +38,9 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { protected $_summary = NULL; protected $_customGroupExtends = array( - 'Contact', 'Individual'); + 'Contact', + 'Individual' + ); public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); @@ -51,154 +53,131 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { function __construct() { $this->_columns = array( - 'civicrm_employer' => - array( + 'civicrm_employer' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'organization_name' => - array('title' => ts('Employer Name'), + 'fields' => array( + 'organization_name' => array( + 'title' => ts('Employer Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'filters' => - array( - 'organization_name' => - array('title' => ts('Employer Name'), + 'filters' => array( + 'organization_name' => array( + 'title' => ts('Employer Name'), 'operatorType' => CRM_Report_Form::OP_STRING, ), ), ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Employee Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Employee Name'), 'required' => TRUE, ), - 'first_name' => array('title' => ts('First Name'), + 'first_name' => array( + 'title' => ts('First Name'), ), - 'last_name' => array('title' => ts('Last Name'), + 'last_name' => array( + 'title' => ts('Last Name'), ), - 'job_title' => - array('title' => ts('Job Title'), + 'job_title' => array( + 'title' => ts('Job Title'), 'default' => TRUE, ), - 'gender_id' => - array('title' => ts('Gender'), + 'gender_id' => array( + 'title' => ts('Gender'), ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Employee Name')), - 'id' => - array('no_display' => TRUE), + 'filters' => array( + 'sort_name' => array('title' => ts('Employee Name')), + 'id' => array('no_display' => TRUE), ), 'grouping' => 'contact-fields', ), - 'civicrm_relationship' => - array( + 'civicrm_relationship' => array( 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => - array( - 'start_date' => - array('title' => ts('Employee Since'), + 'fields' => array( + 'start_date' => array( + 'title' => ts('Employee Since'), 'default' => TRUE, ), ), - 'filters' => - array( - 'start_date' => - array('title' => ts('Employee Since'), + 'filters' => array( + 'start_date' => array( + 'title' => ts('Employee Since'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), ), ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-fields', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), 'default' => TRUE, ), ), ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-fields', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), 'default' => TRUE, ), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), ), ), - 'filters' => - array( - 'country_id' => - array('title' => ts('Country'), + 'filters' => array( + 'country_id' => array( + 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(NULL, FALSE), ), - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), ), ), - 'civicrm_group' => - array( + 'civicrm_group' => array( 'dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', - 'filters' => - array( - 'gid' => - array( + 'filters' => array( + 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), 'group' => TRUE, @@ -224,7 +203,9 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); @@ -268,10 +249,12 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE) { + if (CRM_Utils_Array::value('operatorType', $field) & + CRM_Report_Form::OP_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } @@ -298,7 +281,9 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} $this->_where = "WHERE {$this->_aliases['civicrm_contact']}.employer_id!='null' "; } else { - $this->_where = "WHERE ({$this->_aliases['civicrm_contact']}.employer_id!='null') AND " . implode(' AND ', $clauses); + $this->_where = + "WHERE ({$this->_aliases['civicrm_contact']}.employer_id!='null') AND " . + implode(' AND ', $clauses); } if ($this->_aclWhere) { @@ -316,7 +301,10 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} function postProcess() { // get the acl clauses built before we assemble the query - $this->buildACLClause(array($this->_aliases['civicrm_contact'], $this->_aliases['civicrm_employer'])); + $this->buildACLClause(array( + $this->_aliases['civicrm_contact'], + $this->_aliases['civicrm_employer'] + )); parent::postProcess(); } diff --git a/CRM/Report/Form/Contact/Detail.php b/CRM/Report/Form/Contact/Detail.php index e4a97e65be..476803b5ac 100644 --- a/CRM/Report/Form/Contact/Detail.php +++ b/CRM/Report/Form/Contact/Detail.php @@ -38,7 +38,11 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { protected $_summary = NULL; protected $_customGroupExtends = array( - 'Contact', 'Individual', 'Household', 'Organization'); + 'Contact', + 'Individual', + 'Household', + 'Organization' + ); /** * @@ -49,13 +53,11 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), @@ -65,149 +67,135 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { 'last_name' => array( 'title' => ts('Last Name'), ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), - 'birth_date' => - array( + 'birth_date' => array( 'title' => ts('Birth Date'), ), ), - 'filters' => - array( - 'id' => - array('title' => ts('Contact ID'), + 'filters' => array( + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, ), - 'sort_name' => - array('title' => ts('Contact Name'), + 'sort_name' => array( + 'title' => ts('Contact Name'), ), - 'birth_date' => - array( + 'birth_date' => array( 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, ), ), 'grouping' => 'contact-fields', - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Last Name, First Name'), + 'default' => '1', + 'default_weight' => '0', + 'default_order' => 'ASC' + ), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), ), - 'order_bys' => - array('state_province_id' => array('title' => 'State/Province'), + 'order_bys' => array( + 'state_province_id' => array('title' => 'State/Province'), 'city' => array('title' => 'City'), 'postal_code' => array('title' => 'Postal Code'), ), ), - 'civicrm_country' => - array( + 'civicrm_country' => array( 'dao' => 'CRM_Core_DAO_Country', - 'fields' => - array( - 'name' => - array('title' => 'Country', 'default' => TRUE), + 'fields' => array( + 'name' => array('title' => 'Country', 'default' => TRUE), ), - 'order_bys' => - array( - 'name' => - array('title' => 'Country'), + 'order_bys' => array( + 'name' => array('title' => 'Country'), ), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', - 'order_bys' => - array( - 'email' => - array('title' => ts('Email'), + 'order_bys' => array( + 'email' => array( + 'title' => ts('Email'), ), ), ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contact_id' => - array( + 'fields' => array( + 'contact_id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contribution_id' => - array('title' => ts('Contribution'), + 'contribution_id' => array( + 'title' => ts('Contribution'), 'no_repeat' => TRUE, 'default' => TRUE, ), 'total_amount' => array('default' => TRUE), - 'financial_type_id' => array('title' => ts('Financial Type'), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), 'default' => TRUE, ), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, - 'contribution_status_id' => array('title' => ts('Contribution Status'), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'default' => TRUE, ), 'contribution_source' => NULL, ), ), - 'civicrm_membership' => - array( + 'civicrm_membership' => array( 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => - array( - 'contact_id' => - array( + 'fields' => array( + 'contact_id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'membership_id' => - array('title' => ts('Membership'), + 'membership_id' => array( + 'title' => ts('Membership'), 'no_repeat' => TRUE, 'default' => TRUE, ), - 'membership_type_id' => array('title' => ts('Membership Type'), + 'membership_type_id' => array( + 'title' => ts('Membership Type'), 'default' => TRUE, ), 'join_date' => NULL, - 'membership_start_date' => array('title' => ts('Start Date'), + 'membership_start_date' => array( + 'title' => ts('Start Date'), 'default' => TRUE, ), - 'membership_end_date' => array('title' => ts('End Date'), + 'membership_end_date' => array( + 'title' => ts('End Date'), 'default' => TRUE, ), 'membership_status_id' => array( @@ -218,18 +206,15 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { 'source' => array('title' => 'Membership Source'), ), ), - 'civicrm_participant' => - array( + 'civicrm_participant' => array( 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => - array( - 'contact_id' => - array( + 'fields' => array( + 'contact_id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'participant_id' => - array('title' => ts('Participant'), + 'participant_id' => array( + 'title' => ts('Participant'), 'no_repeat' => TRUE, 'default' => TRUE, ), @@ -239,76 +224,72 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { 'title' => ts('Participant Status'), 'default' => TRUE, ), - 'role_id' => array('title' => ts('Role'), + 'role_id' => array( + 'title' => ts('Role'), 'default' => TRUE, ), - 'participant_register_date' => array('title' => ts('Register Date'), + 'participant_register_date' => array( + 'title' => ts('Register Date'), 'default' => TRUE, ), - 'fee_level' => array('title' => ts('Fee Level'), + 'fee_level' => array( + 'title' => ts('Fee Level'), 'default' => TRUE, ), - 'fee_amount' => array('title' => ts('Fee Amount'), + 'fee_amount' => array( + 'title' => ts('Fee Amount'), 'default' => TRUE, ), ), ), - 'civicrm_relationship' => - array( + 'civicrm_relationship' => array( 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => - array( - 'relationship_id' => - array( + 'fields' => array( + 'relationship_id' => array( 'name' => 'id', 'title' => ts('Relationship'), 'no_repeat' => TRUE, 'default' => TRUE, ), - 'relationship_type_id' => - array('title' => ts('Relationship Type'), + 'relationship_type_id' => array( + 'title' => ts('Relationship Type'), 'default' => TRUE, ), - 'contact_id_b' => - array('title' => ts('Relationship With'), + 'contact_id_b' => array( + 'title' => ts('Relationship With'), 'default' => TRUE, ), - 'start_date' => - array( + 'start_date' => array( 'title' => 'Start Date ', 'type' => CRM_Report_Form::OP_DATE, ), - 'end_date' => - array( + 'end_date' => array( 'title' => 'End Date ', 'type' => CRM_Report_Form::OP_DATE, ), ), ), - 'civicrm_activity' => - array( + 'civicrm_activity' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array( - 'id' => - array('title' => ts('Activity'), + 'fields' => array( + 'id' => array( + 'title' => ts('Activity'), 'no_repeat' => TRUE, 'default' => TRUE, ), - 'activity_type_id' => - array('title' => ts('Activity Type'), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), 'default' => TRUE, ), - 'subject' => - array('title' => ts('Subject'), + 'subject' => array( + 'title' => ts('Subject'), 'default' => TRUE, ), - 'activity_date_time' => - array('title' => ts('Activity Date'), + 'activity_date_time' => array( + 'title' => ts('Activity Date'), 'default' => TRUE, ), - 'activity_status_id' => - array( + 'activity_status_id' => array( 'name' => 'status_id', 'title' => ts('Activity Status'), 'default' => TRUE, @@ -316,54 +297,44 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { ), 'grouping' => 'activity-fields', ), - 'civicrm_activity_target' => - array( + 'civicrm_activity_target' => array( 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - 'target_contact_id' => - array('title' => ts('With Contact'), + 'fields' => array( + 'target_contact_id' => array( + 'title' => ts('With Contact'), 'name' => 'contact_id', 'default' => TRUE, ), ), 'grouping' => 'activity-fields', ), - 'civicrm_activity_assignment' => - array( + 'civicrm_activity_assignment' => array( 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - 'assignee_contact_id' => - array('title' => ts('Assigned to'), + 'fields' => array( + 'assignee_contact_id' => array( + 'title' => ts('Assigned to'), 'name' => 'contact_id', 'default' => TRUE, ), ), 'grouping' => 'activity-fields', ), - 'civicrm_activity_source' => - array( - 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - 'source_contact_id' => - array( - 'title' => ts('Added By'), - 'name' => 'contact_id', - 'default' => TRUE, - ), + 'civicrm_activity_source' => array( + 'dao' => 'CRM_Activity_DAO_ActivityContact', + 'fields' => array( + 'source_contact_id' => array( + 'title' => ts('Added By'), + 'name' => 'contact_id', + 'default' => TRUE, ), + ), 'grouping' => 'activity-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( + 'fields' => array( 'phone' => NULL, - 'phone_ext' => - array( + 'phone_ext' => array( 'title' => ts('Phone Extension') ) ), @@ -383,25 +354,38 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { function select() { $select = array(); $this->_columnHeaders = array(); - $this->_component = array('contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport'); + $this->_component = array( + 'contribution_civireport', + 'membership_civireport', + 'participant_civireport', + 'relationship_civireport', + 'activity_civireport' + ); foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { //isolate the select clause compoenent wise if (in_array($table['alias'], $this->_component)) { $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); } - elseif ($table['alias'] == $this->_aliases['civicrm_activity_target'] || - $table['alias'] == $this->_aliases['civicrm_activity_assignment'] || + elseif ($table['alias'] == + $this->_aliases['civicrm_activity_target'] || + $table['alias'] == + $this->_aliases['civicrm_activity_assignment'] || $table['alias'] == $this->_aliases['civicrm_activity_source'] ) { - if ($table['alias'] == $this->_aliases['civicrm_activity_target']) { + if ($table['alias'] == $this->_aliases['civicrm_activity_target'] + ) { $addContactId = 'civicrm_activity_target.contact_id as target_contact_id'; } - elseif ($table['alias'] == $this->_aliases['civicrm_activity_source']) { + elseif ($table['alias'] == + $this->_aliases['civicrm_activity_source'] + ) { $addContactId = 'civicrm_activity_source.contact_id'; } else { @@ -425,7 +409,8 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { foreach ($this->_component as $val) { if (!empty($select[$val])) { - $this->_selectComponent[$val] = "SELECT " . implode(', ', $select[$val]) . " "; + $this->_selectComponent[$val] = + "SELECT " . implode(', ', $select[$val]) . " "; unset($select[$val]); } } @@ -450,7 +435,9 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { $this->_from = " FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}"; - if ($this->isTableSelected('civicrm_country') || $this->isTableSelected('civicrm_address')) { + if ($this->isTableSelected('civicrm_country') || + $this->isTableSelected('civicrm_address') + ) { $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND @@ -558,10 +545,12 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE) { + if (CRM_Utils_Array::value('operatorType', $field) & + CRM_Report_Form::OP_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } @@ -600,10 +589,12 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { */ function clauseComponent() { $selectedContacts = implode(',', $this->_contactSelected); - $contribution = $membership = $participant = NULL; - $eligibleResult = $rows = $tempArray = array(); + $contribution = $membership = $participant = NULL; + $eligibleResult = $rows = $tempArray = array(); foreach ($this->_component as $val) { - if (!empty($this->_selectComponent[$val]) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) { + if (!empty($this->_selectComponent[$val]) && + ($val != 'activity_civireport' && $val != 'relationship_civireport') + ) { $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]} WHERE {$this->_aliases['civicrm_contact']}.id IN ( $selectedContacts ) GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id "; @@ -655,13 +646,15 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { $row[$key] = $dao->$key; } - $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . '_a_b'; + $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . + '_a_b'; $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle]; $rows[$dao->contact_a_id][$val][] = $row; $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name; - $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . '_b_a'; + $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . + '_b_a'; if (isset($relTypes[$relTitle])) { $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle]; } @@ -672,11 +665,12 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { if (!empty($this->_selectComponent['activity_civireport'])) { $componentClause = "civicrm_option_value.component_id IS NULL"; - $componentsIn = NULL; - $compInfo = CRM_Core_Component::getEnabledComponents(); + $componentsIn = NULL; + $compInfo = CRM_Core_Component::getEnabledComponents(); foreach ($compInfo as $compObj) { if ($compObj->info['showActivitiesInCore']) { - $componentsIn = $componentsIn ? ($componentsIn . ', ' . $compObj->componentID) : $compObj->componentID; + $componentsIn = $componentsIn ? ($componentsIn . ', ' . + $compObj->componentID) : $compObj->componentID; } } if ($componentsIn) { @@ -793,10 +787,15 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { //unset Conmponent id and contact id from display foreach ($this->_columnHeadersComponent as $componentTitle => $headers) { - $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . substr_replace($componentTitle, '', -11, 11) . '_id'; - $contact_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_contact_id'; + $id_header = + 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_' . + substr_replace($componentTitle, '', -11, 11) . '_id'; + $contact_header = + 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . + '_contact_id'; if ($componentTitle == 'activity_civireport') { - $id_header = 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id'; + $id_header = + 'civicrm_' . substr_replace($componentTitle, '', -11, 11) . '_id'; } unset($this->_columnHeadersComponent[$componentTitle][$id_header]); @@ -868,7 +867,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { if ($component == 'contribution_civireport') { if ($val = CRM_Utils_Array::value('civicrm_contribution_financial_type_id', $row)) { $componentRows[$contactID][$component][$rowNum]['civicrm_contribution_financial_type_id'] = - CRM_Contribute_PseudoConstant::financialType($val, false); + CRM_Contribute_PseudoConstant::financialType($val, FALSE); } if ($val = CRM_Utils_Array::value('civicrm_contribution_contribution_status_id', $row)) { diff --git a/CRM/Report/Form/Contact/Log.php b/CRM/Report/Form/Contact/Log.php index 678ba313c7..d08573cb96 100644 --- a/CRM/Report/Form/Contact/Log.php +++ b/CRM/Report/Form/Contact/Log.php @@ -49,101 +49,89 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { asort($this->activityTypes); $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Modified By'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Modified By'), 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Modified By'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Modified By'), 'type' => CRM_Utils_Type::T_STRING, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_contact_touched' => - array( + 'civicrm_contact_touched' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name_touched' => - array('title' => ts('Touched Contact'), + 'fields' => array( + 'sort_name_touched' => array( + 'title' => ts('Touched Contact'), 'name' => 'sort_name', 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'filters' => - array( - 'sort_name_touched' => - array('title' => ts('Touched Contact'), + 'filters' => array( + 'sort_name_touched' => array( + 'title' => ts('Touched Contact'), 'name' => 'sort_name', 'type' => CRM_Utils_Type::T_STRING, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_activity' => - array( + 'civicrm_activity' => array( 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => - array('id' => array('title' => ts('Activity ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE, ), - 'subject' => array('title' => ts('Touched Activity'), + 'subject' => array( + 'title' => ts('Touched Activity'), 'required' => TRUE, ), - 'activity_type_id' => array('title' => ts('Activity Type'), + 'activity_type_id' => array( + 'title' => ts('Activity Type'), 'required' => TRUE, ), ), ), - 'civicrm_activity_source' => - array( + 'civicrm_activity_source' => array( 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => - array( - 'contact_id' => - array( + 'fields' => array( + 'contact_id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), ), - 'civicrm_log' => - array( + 'civicrm_log' => array( 'dao' => 'CRM_Core_DAO_Log', - 'fields' => - array( - 'modified_date' => - array('title' => ts('Modified Date'), + 'fields' => array( + 'modified_date' => array( + 'title' => ts('Modified Date'), 'required' => TRUE, ), - 'data' => - array('title' => ts('Description'), + 'data' => array( + 'title' => ts('Description'), ), ), - 'filters' => - array( - 'modified_date' => - array('title' => ts('Modified Date'), + 'filters' => array( + 'modified_date' => array( + 'title' => ts('Modified Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'default' => 'this.week', @@ -165,7 +153,9 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); @@ -211,10 +201,12 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE) { + if (CRM_Utils_Array::value('operatorType', $field) & + CRM_Report_Form::OP_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } @@ -285,7 +277,9 @@ ORDER BY {$this->_aliases['civicrm_log']}.modified_date DESC, {$this->_aliases[' $row['civicrm_activity_subject'] !== '' ) { $url = CRM_Utils_System::url('civicrm/contact/view/activity', - 'reset=1&action=view&id=' . $row['civicrm_activity_id'] . '&cid=' . $row['civicrm_activity_source_contact_id'] . '&atype=' . $row['civicrm_activity_activity_type_id'], + 'reset=1&action=view&id=' . $row['civicrm_activity_id'] . '&cid=' . + $row['civicrm_activity_source_contact_id'] . '&atype=' . + $row['civicrm_activity_activity_type_id'], $this->_absoluteUrl ); $rows[$rowNum]['civicrm_activity_subject_link'] = $url; diff --git a/CRM/Report/Form/Contact/Relationship.php b/CRM/Report/Form/Contact/Relationship.php index 1f2041b2a5..ffbd8ab753 100644 --- a/CRM/Report/Form/Contact/Relationship.php +++ b/CRM/Report/Form/Contact/Relationship.php @@ -41,7 +41,8 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { protected $_phoneField_a = FALSE; protected $_phoneField_b = FALSE; protected $_customGroupExtends = array( - 'Relationship'); + 'Relationship' + ); public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); function __construct() { @@ -49,42 +50,36 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '_'); $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name_a' => - array('title' => ts('Contact A'), + 'fields' => array( + 'sort_name_a' => array( + 'title' => ts('Contact A'), 'name' => 'sort_name', 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type_a' => - array( + 'contact_type_a' => array( 'title' => ts('Contact Type (Contact A)'), 'name' => 'contact_type', ), - 'contact_sub_type_a' => - array( + 'contact_sub_type_a' => array( 'title' => ts('Contact Subtype (Contact A)'), 'name' => 'contact_sub_type', ), ), - 'filters' => - array( - 'sort_name_a' => - array('title' => ts('Contact A'), + 'filters' => array( + 'sort_name_a' => array( + 'title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, ), - 'contact_type_a' => - array('title' => ts('Contact Type A'), + 'contact_type_a' => array( + 'title' => ts('Contact Type A'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, @@ -93,43 +88,37 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { ), 'grouping' => 'conact_a_fields', ), - 'civicrm_contact_b' => - array( + 'civicrm_contact_b' => array( 'dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', - 'fields' => - array( - 'sort_name_b' => - array('title' => ts('Contact B'), + 'fields' => array( + 'sort_name_b' => array( + 'title' => ts('Contact B'), 'name' => 'sort_name', 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type_b' => - array( + 'contact_type_b' => array( 'title' => ts('Contact Type (Contact B)'), 'name' => 'contact_type', ), - 'contact_sub_type_b' => - array( + 'contact_sub_type_b' => array( 'title' => ts('Contact Subtype (Contact B)'), 'name' => 'contact_sub_type', ), ), - 'filters' => - array( - 'sort_name_b' => - array('title' => ts('Contact B'), + 'filters' => array( + 'sort_name_b' => array( + 'title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, ), - 'contact_type_b' => - array('title' => ts('Contact Type B'), + 'contact_type_b' => array( + 'title' => ts('Contact Type B'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, @@ -138,142 +127,121 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { ), 'grouping' => 'conact_b_fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email_a' => - array('title' => ts('Email (Contact A)'), + 'fields' => array( + 'email_a' => array( + 'title' => ts('Email (Contact A)'), 'name' => 'email', ), ), 'grouping' => 'conact_a_fields', ), - 'civicrm_email_b' => - array( + 'civicrm_email_b' => array( 'dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', - 'fields' => - array( - 'email_b' => - array('title' => ts('Email (Contact B)'), + 'fields' => array( + 'email_b' => array( + 'title' => ts('Email (Contact B)'), 'name' => 'email', ), ), 'grouping' => 'conact_b_fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_a', - 'fields' => - array( - 'phone_a' => - array( + 'fields' => array( + 'phone_a' => array( 'title' => ts('Phone (Contact A)'), 'name' => 'phone', ), - 'phone_ext_a' => - array( + 'phone_ext_a' => array( 'title' => ts('Phone Ext (Contact A)'), 'name' => 'phone_ext', ), ), 'grouping' => 'conact_a_fields', ), - 'civicrm_phone_b' => - array( + 'civicrm_phone_b' => array( 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_b', - 'fields' => - array( - 'phone_b' => - array( + 'fields' => array( + 'phone_b' => array( 'title' => ts('Phone (Contact B)'), 'name' => 'phone' ), - 'phone_ext_b' => - array( + 'phone_ext_b' => array( 'title' => ts('Phone Ext (Contact B)'), 'name' => 'phone_ext' ), ), 'grouping' => 'conact_b_fields', ), - 'civicrm_relationship_type' => - array( + 'civicrm_relationship_type' => array( 'dao' => 'CRM_Contact_DAO_RelationshipType', - 'fields' => - array( - 'label_a_b' => - array('title' => ts('Relationship A-B '), + 'fields' => array( + 'label_a_b' => array( + 'title' => ts('Relationship A-B '), 'default' => TRUE, ), - 'label_b_a' => - array('title' => ts('Relationship B-A '), + 'label_b_a' => array( + 'title' => ts('Relationship B-A '), 'default' => TRUE, ), ), 'grouping' => 'relation-fields', ), - 'civicrm_relationship' => - array( + 'civicrm_relationship' => array( 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => - array( - 'start_date' => - array('title' => ts('Relationship Start Date'), + 'fields' => array( + 'start_date' => array( + 'title' => ts('Relationship Start Date'), ), - 'end_date' => - array('title' => ts('Relationship End Date'), + 'end_date' => array( + 'title' => ts('Relationship End Date'), ), - 'description' => - array('title' => ts('Description'), + 'description' => array( + 'title' => ts('Description'), ), - 'relationship_id' => - array( + 'relationship_id' => array( 'title' => ts('Rel ID'), 'name' => 'id', ), ), - 'filters' => - array( - 'is_active' => - array('title' => ts('Relationship Status'), + 'filters' => array( + 'is_active' => array( + 'title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => - array( + 'options' => array( '' => '- Any -', 1 => 'Active', 0 => 'Inactive', ), 'type' => CRM_Utils_Type::T_INT, ), - 'relationship_type_id' => - array('title' => ts('Relationship'), + 'relationship_type_id' => array( + 'title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => - array( - '' => '- any relationship type -') + - CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE), + 'options' => array( + '' => '- any relationship type -' + ) + + CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE), 'type' => CRM_Utils_Type::T_INT, ), ), 'grouping' => 'relation-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'filters' => - array( - 'country_id' => - array('title' => ts('Country'), + 'filters' => array( + 'country_id' => array( + 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), @@ -296,7 +264,9 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($fieldName == 'email_a') { $this->_emailField_a = TRUE; @@ -304,10 +274,10 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { if ($fieldName == 'email_b') { $this->_emailField_b = TRUE; } - if ($fieldName == 'phone_a'){ + if ($fieldName == 'phone_a') { $this->_phoneField_a = TRUE; } - if ($fieldName == 'phone_b'){ + if ($fieldName == 'phone_b') { $this->_phoneField_b = TRUE; } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; @@ -393,26 +363,32 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); if ($op) { - if (($tableName == 'civicrm_contact' || $tableName == 'civicrm_contact_b') && - ($fieldName == 'contact_type_a' || $fieldName == 'contact_type_b') + if (($tableName == 'civicrm_contact' || + $tableName == 'civicrm_contact_b') && + ($fieldName == 'contact_type_a' || + $fieldName == 'contact_type_b') ) { $cTypes = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); $contactTypes = $contactSubTypes = array(); if (!empty($cTypes)) { foreach ($cTypes as $ctype) { $getTypes = CRM_Utils_System::explode('_', $ctype, 2); - if ($getTypes[1] && !in_array($getTypes[1], $contactSubTypes)) { + if ($getTypes[1] && + !in_array($getTypes[1], $contactSubTypes) + ) { $contactSubTypes[] = $getTypes[1]; } - elseif ($getTypes[0] && !in_array($getTypes[0], $contactTypes)) { + elseif ($getTypes[0] && + !in_array($getTypes[0], $contactTypes) + ) { $contactTypes[] = $getTypes[0]; } } @@ -507,7 +483,9 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { //for displaying relationship type filter if ($value['title'] == 'Relationship') { $relTypes = CRM_Core_PseudoConstant::relationshipType(); - $statistics['filters'][$id]['value'] = 'Is equal to ' . $relTypes[$this->_params['relationship_type_id_value']]['label_' . $this->relationType]; + $statistics['filters'][$id]['value'] = 'Is equal to ' . + $relTypes[$this->_params['relationship_type_id_value']]['label_' . + $this->relationType]; } //for displaying relationship status @@ -538,7 +516,8 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { } if (!empty($groupBy)) { - $this->_groupBy = " GROUP BY " . implode(', ', $groupBy) . " , {$this->_aliases['civicrm_relationship']}.id "; + $this->_groupBy = " GROUP BY " . implode(', ', $groupBy) . + " , {$this->_aliases['civicrm_relationship']}.id "; } else { $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_relationship']}.id "; @@ -561,7 +540,10 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $this->_params['relationship_type_id_value'] = intval($relType[0]); } - $this->buildACLClause(array($this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_b'])); + $this->buildACLClause(array( + $this->_aliases['civicrm_contact'], + $this->_aliases['civicrm_contact_b'] + )); $sql = $this->buildQuery(); $this->buildRows($sql, $rows); @@ -606,7 +588,9 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); - $rows[$rowNum]['civicrm_contact_sort_name_a'] = $rows[$rowNum]['civicrm_contact_sort_name_a'] . ' (' . $rows[$rowNum]['civicrm_contact_id'] . ')'; + $rows[$rowNum]['civicrm_contact_sort_name_a'] = + $rows[$rowNum]['civicrm_contact_sort_name_a'] . ' (' . + $rows[$rowNum]['civicrm_contact_id'] . ')'; $rows[$rowNum]['civicrm_contact_sort_name_a_link'] = $url; $rows[$rowNum]['civicrm_contact_sort_name_a_hover'] = ts("View Contact details for this contact."); $entryFound = TRUE; @@ -619,14 +603,21 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_b_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); - $rows[$rowNum]['civicrm_contact_b_sort_name_b'] = $rows[$rowNum]['civicrm_contact_b_sort_name_b'] . ' (' . $rows[$rowNum]['civicrm_contact_b_id'] . ')'; + $rows[$rowNum]['civicrm_contact_b_sort_name_b'] = + $rows[$rowNum]['civicrm_contact_b_sort_name_b'] . ' (' . + $rows[$rowNum]['civicrm_contact_b_id'] . ')'; $rows[$rowNum]['civicrm_contact_b_sort_name_b_link'] = $url; $rows[$rowNum]['civicrm_contact_b_sort_name_b_hover'] = ts("View Contact details for this contact."); $entryFound = TRUE; } - if (array_key_exists('civicrm_relationship_relationship_id', $row) && array_key_exists('civicrm_contact_id', $row)) { - $url = "/civicrm/contact/view/rel?reset=1&action=update&rtype=a_b&cid=" . $row['civicrm_contact_id'] . "&id=" . $row['civicrm_relationship_relationship_id']; + if (array_key_exists('civicrm_relationship_relationship_id', $row) && + array_key_exists('civicrm_contact_id', $row) + ) { + $url = + "/civicrm/contact/view/rel?reset=1&action=update&rtype=a_b&cid=" . + $row['civicrm_contact_id'] . "&id=" . + $row['civicrm_relationship_relationship_id']; $rows[$rowNum]['civicrm_relationship_relationship_id_link'] = $url; $rows[$rowNum]['civicrm_relationship_relationship_id_hover'] = ts("Edit this relationship."); $entryFound = TRUE; diff --git a/CRM/Report/Form/Contact/Summary.php b/CRM/Report/Form/Contact/Summary.php index 2ab122ee62..72472c9072 100644 --- a/CRM/Report/Form/Contact/Summary.php +++ b/CRM/Report/Form/Contact/Summary.php @@ -42,7 +42,11 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form { protected $_phoneField = FALSE; protected $_customGroupExtends = array( - 'Contact', 'Individual', 'Household', 'Organization'); + 'Contact', + 'Individual', + 'Household', + 'Organization' + ); public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); @@ -52,124 +56,108 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form { function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), - 'required' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'middle_name' => array( + 'title' => ts('Middle Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), + 'gender_id' => array( + 'title' => ts('Gender'), + ), + 'birth_date' => array( + 'title' => ts('Birth Date'), + ), + 'age' => array( + 'title' => ts('Age'), + 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', + ), ), - 'first_name' => array( - 'title' => ts('First Name'), + 'filters' => array( + 'sort_name' => array('title' => ts('Contact Name')), + 'source' => array( + 'title' => ts('Contact Source'), + 'type' => CRM_Utils_Type::T_STRING, + ), + 'id' => array( + 'title' => ts('Contact ID'), + 'no_display' => TRUE, + ), + 'gender_id' => array( + 'title' => ts('Gender'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), + ), + 'birth_date' => array( + 'title' => ts('Birth Date'), + 'operatorType' => CRM_Report_Form::OP_DATE, + ), ), - 'middle_name' => array( - 'title' => ts('Middle Name'), - ), - 'last_name' => array( - 'title' => ts('Last Name'), - ), - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - ), - 'gender_id' => - array('title' => ts('Gender'), - ), - 'birth_date' => - array( - 'title' => ts('Birth Date'), - ), - 'age' => array( - 'title' => ts('Age'), - 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name')), - 'source' => - array('title' => ts('Contact Source'), - 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => - array('title' => ts('Contact ID'), - 'no_display' => TRUE, - ), - 'gender_id' => - array('title' => ts('Gender'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => - array( - 'title' => ts('Birth Date'), - 'operatorType' => CRM_Report_Form::OP_DATE, + 'grouping' => 'contact-fields', + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Last Name, First Name'), + 'default' => '1', + 'default_weight' => '0', + 'default_order' => 'ASC', + ), + 'gender_id' => array( + 'name' => 'gender_id', + 'title' => ts('Gender'), + ), + 'birth_date' => array( + 'name' => 'birth_date', + 'title' => ts('Birth Date'), + ), ), ), - 'grouping' => 'contact-fields', - 'order_bys' => - array( - 'sort_name' => - array( - 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'no_repeat' => TRUE, + ), ), - 'gender_id' => - array( - 'name' => 'gender_id', - 'title' => ts('Gender'), - ), - 'birth_date' => - array( - 'name' => 'birth_date', - 'title' => ts('Birth Date'), - ), - ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'no_repeat' => TRUE, + 'grouping' => 'contact-fields', + 'order_bys' => array( + 'email' => array( + 'title' => ts('Email'), + ), ), ), - 'grouping' => 'contact-fields', - 'order_bys' => - array( - 'email' => - array('title' => ts('Email'), + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => NULL, + 'phone_ext' => array( + 'title' => ts('Phone Extension') + ) ), + 'grouping' => 'contact-fields', ), - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => NULL, - 'phone_ext' => - array( - 'title' => ts('Phone Extension') - ) - ), - 'grouping' => 'contact-fields', - ), - ) + $this->getAddressColumns(array('group_by' => FALSE)); + ) + $this->getAddressColumns(array('group_by' => FALSE)); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -186,7 +174,9 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -271,7 +261,7 @@ class CRM_Report_Form_Contact_Summary extends CRM_Report_Form { /** * @param $rows */ - private function _initBasicRow(&$rows, &$entryFound, $row, $rowId, $rowNum, $types){ + private function _initBasicRow(&$rows, &$entryFound, $row, $rowId, $rowNum, $types) { if (!array_key_exists($rowId, $row)) { return FALSE; } diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index f94eb7cf4a..d91ae025fe 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -41,7 +41,8 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { protected $_summary = NULL; protected $_customGroupExtends = array( - 'Membership'); + 'Membership' + ); /** * @@ -51,56 +52,47 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'operator' => 'like', ), - 'id' => - array('title' => ts('Contact ID'), + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, ), ), - 'order_bys' => - array( + 'order_bys' => array( 'sort_name' => array( 'title' => ts('Last Name, First Name'), ), ), 'grouping' => 'contact-fields', ), - 'civicrm_membership' => - array( + 'civicrm_membership' => array( 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => - array( - 'id' => - array('title' => ts('Membership #'), + 'fields' => array( + 'id' => array( + 'title' => ts('Membership #'), 'no_display' => TRUE, 'required' => TRUE, ), @@ -111,25 +103,25 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'fields' => array( 'debit_accounting_code' => array( 'title' => ts('Financial Account Code - Debit'), - 'name' => 'accounting_code', + 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE, ), 'credit_accounting_code' => array( 'title' => ts('Financial Account Code - Credit'), - 'name' => 'accounting_code', + 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE, ), 'debit_name' => array( 'title' => ts('Financial Account Name - Debit'), - 'name' => 'name', + 'name' => 'name', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE, ), 'credit_name' => array( 'title' => ts('Financial Account Name - Credit'), - 'name' => 'name', + 'name' => 'name', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE, ), @@ -139,7 +131,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'title' => ts('Financial Account Code - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), - 'name' => 'accounting_code', + 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', ), 'credit_accounting_code' => array( @@ -151,7 +143,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'title' => ts('Financial Account Name - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), - 'name' => 'id', + 'name' => 'id', 'alias' => 'financial_account_civireport_debit', ), 'credit_name' => array( @@ -164,7 +156,8 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'civicrm_line_item' => array( 'dao' => 'CRM_Price_DAO_LineItem', 'fields' => array( - 'financial_type_id' => array('title' => ts('Financial Type'), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), 'default' => TRUE, ), ), @@ -179,11 +172,9 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'financial_type_id' => array('title' => ts('Financial Type')), ), ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( + 'fields' => array( 'receive_date' => array( 'default' => TRUE ), @@ -191,19 +182,19 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'title' => ts('Invoice ID'), 'default' => TRUE, ), - 'contribution_status_id' => array('title' => ts('Contribution Status'), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'default' => TRUE, ), - 'id' => array('title' => ts('Contribution #'), + 'id' => array( + 'title' => ts('Contribution #'), 'default' => TRUE, ), ), - 'filters' => - array( - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1), @@ -222,12 +213,13 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'title' => ts('Cheque #'), 'default' => TRUE, ), - 'payment_instrument_id' => array('title' => ts('Payment Instrument'), + 'payment_instrument_id' => array( + 'title' => ts('Payment Instrument'), 'default' => TRUE, ), 'currency' => array( - 'required' => TRUE, - 'no_display' => TRUE, + 'required' => TRUE, + 'no_display' => TRUE, ), 'trxn_date' => array( 'title' => ts('Transaction Date'), @@ -239,19 +231,18 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'default' => TRUE, ), ), - 'filters' => - array( + 'filters' => array( 'payment_instrument_id' => array( 'title' => ts('Payment Instrument'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), 'currency' => array( - 'title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, ), 'trxn_date' => array( 'title' => ts('Transaction Date'), @@ -272,10 +263,8 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'type' => CRM_Utils_Type::T_STRING, ), ), - 'filters' => - array( - 'amount' => - array('title' => ts('Amount')), + 'filters' => array( + 'amount' => array('title' => ts('Amount')), ), ), ); @@ -296,32 +285,34 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { switch ($fieldName) { - case 'credit_accounting_code' : - $select[] = " CASE + case 'credit_accounting_code' : + $select[] = " CASE WHEN {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id IS NOT NULL THEN {$this->_aliases['civicrm_financial_account']}_credit_1.accounting_code ELSE {$this->_aliases['civicrm_financial_account']}_credit_2.accounting_code END AS civicrm_financial_account_credit_accounting_code "; - break; - case 'amount' : - $select[] = " CASE + break; + case 'amount' : + $select[] = " CASE WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount END AS civicrm_entity_financial_trxn_amount "; - break; - case 'credit_name' : - $select[] = " CASE + break; + case 'credit_name' : + $select[] = " CASE WHEN {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id IS NOT NULL THEN {$this->_aliases['civicrm_financial_account']}_credit_1.name ELSE {$this->_aliases['civicrm_financial_account']}_credit_2.name END AS civicrm_financial_account_credit_name "; - break; - default : - $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - break; + break; + default : + $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; + break; } $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); @@ -370,7 +361,9 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { // please note this will just add the order-by columns to select query, and not display in column-headers. // This is a solution to not throw fatal errors when there is a column in order-by, not present in select/display columns. foreach ($this->_orderByFields as $orderBy) { - if (!array_key_exists($orderBy['name'], $this->_params['fields']) && empty($orderBy['section'])) { + if (!array_key_exists($orderBy['name'], $this->_params['fields']) && + empty($orderBy['section']) + ) { $this->_select .= ", {$orderBy['dbAlias']} as {$orderBy['tplField']}"; } } @@ -397,8 +390,8 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { } if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } @@ -457,13 +450,14 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { $amount[] = CRM_Utils_Money::format($dao->amount, $dao->currency); - $avg[] = CRM_Utils_Money::format(round(($dao->amount / $dao->count), 2), $dao->currency); + $avg[] = CRM_Utils_Money::format(round(($dao->amount / + $dao->count), 2), $dao->currency); } $statistics['counts']['amount'] = array( - 'value' => implode(', ', $amount), - 'title' => 'Total Amount', - 'type' => CRM_Utils_Type::T_STRING, + 'value' => implode(', ', $amount), + 'title' => 'Total Amount', + 'type' => CRM_Utils_Type::T_STRING, ); $statistics['counts']['avg'] = array( 'value' => implode(', ', $avg), @@ -482,7 +476,8 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); foreach ($rows as $rowNum => $row) { // convert display name to links - if (array_key_exists('civicrm_contact_sort_name', $row) && !empty($rows[$rowNum]['civicrm_contact_sort_name']) && + if (array_key_exists('civicrm_contact_sort_name', $row) && + !empty($rows[$rowNum]['civicrm_contact_sort_name']) && array_key_exists('civicrm_contact_id', $row) ) { $url = CRM_Utils_System::url('civicrm/contact/view', @@ -508,7 +503,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { $rows[$rowNum]['civicrm_line_item_financial_type_id'] = $contributionTypes[$value]; } if ($value = CRM_Utils_Array::value('civicrm_entity_financial_trxn_amount', $row)) { - $rows[$rowNum]['civicrm_entity_financial_trxn_amount'] = CRM_Utils_Money::format($rows[$rowNum]['civicrm_entity_financial_trxn_amount'],$rows[$rowNum]['civicrm_financial_trxn_currency']); + $rows[$rowNum]['civicrm_entity_financial_trxn_amount'] = CRM_Utils_Money::format($rows[$rowNum]['civicrm_entity_financial_trxn_amount'], $rows[$rowNum]['civicrm_financial_trxn_currency']); } } } diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 05412ac832..8cea5560cd 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -42,7 +42,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { protected $_softFrom = NULL; - protected $_customGroupExtends = array( 'Contribution'); + protected $_customGroupExtends = array('Contribution'); /** * @@ -61,251 +61,233 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { asort($this->activeCampaigns); } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'required' => TRUE, - ), - 'first_name' => array('title' => ts('First Name'), - ), - 'last_name' => array('title' => ts('Last Name'), - ), - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'operator' => 'like', - ), - 'id' => - array('title' => ts('Contact ID'), - 'no_display' => TRUE, - 'type' => CRM_Utils_Type::T_INT, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'required' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), ), - ), - 'order_bys' => - array( - 'sort_name' => array( - 'title' => ts('Last Name, First Name'), - 'default' => '1', - 'default_weight' => '0', - 'default_order' => 'ASC' + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'operator' => 'like', + ), + 'id' => array( + 'title' => ts('Contact ID'), + 'no_display' => TRUE, + 'type' => CRM_Utils_Type::T_INT, + ), ), - ), - 'grouping' => 'contact-fields', - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Donor Email'), - 'default' => TRUE, + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Last Name, First Name'), + 'default' => '1', + 'default_weight' => '0', + 'default_order' => 'ASC' + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Donor Phone'), - 'default' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Donor Email'), + 'default' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contribution_id' => array( - 'name' => 'id', - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'list_contri_id' => array( - 'name' => 'id', - 'title' => ts('Contribution ID'), - ), - 'financial_type_id' => array('title' => ts('Financial Type'), - 'default' => TRUE, - ), - 'contribution_status_id' => array('title' => ts('Contribution Status'), - ), - 'contribution_page_id' => array('title' => ts('Contribution Page'), - ), - 'source' => array('title' => ts('Source'), - ), - 'payment_instrument_id' => array('title' => ts('Payment Type'), - ), - 'check_number' => array('title' => ts('Check Number'), - ), - 'currency' => - array('required' => TRUE, - 'no_display' => TRUE, - ), - 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), - 'receipt_date' => NULL, - 'total_amount' => array('title' => ts('Amount'), - 'required' => TRUE, - 'statistics' => - array('sum' => ts('Amount')), - ), - 'fee_amount' => NULL, - 'net_amount' => NULL, - 'contribution_or_soft' => - array('title' => ts('Contribution OR Soft Credit?'), - 'dbAlias' => "'Contribution'" - ), - 'soft_credits' => - array('title' => ts('Soft Credits'), - 'dbAlias' => "NULL" - ), - 'soft_credit_for' => - array('title' => ts('Soft Credit For'), - 'dbAlias' => "NULL" + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Donor Phone'), + 'default' => TRUE, + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'filters' => - array( - 'contribution_or_soft' => - array('title' => ts('Contribution OR Soft Credit?'), - 'clause' => "(1)", - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'type' => CRM_Utils_Type::T_STRING, - 'options' => array( - 'both' => ts('Both'), - 'contributions_only' => ts('Contributions Only'), - 'soft_credits_only' => ts('Soft Credits Only'), + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'contribution_id' => array( + 'name' => 'id', + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'list_contri_id' => array( + 'name' => 'id', + 'title' => ts('Contribution ID'), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'default' => TRUE, + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + ), + 'contribution_page_id' => array( + 'title' => ts('Contribution Page'), + ), + 'source' => array( + 'title' => ts('Source'), + ), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), + ), + 'check_number' => array( + 'title' => ts('Check Number'), + ), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, + ), + 'trxn_id' => NULL, + 'receive_date' => array('default' => TRUE), + 'receipt_date' => NULL, + 'total_amount' => array( + 'title' => ts('Amount'), + 'required' => TRUE, + 'statistics' => array('sum' => ts('Amount')), + ), + 'fee_amount' => NULL, + 'net_amount' => NULL, + 'contribution_or_soft' => array( + 'title' => ts('Contribution OR Soft Credit?'), + 'dbAlias' => "'Contribution'" + ), + 'soft_credits' => array( + 'title' => ts('Soft Credits'), + 'dbAlias' => "NULL" + ), + 'soft_credit_for' => array( + 'title' => ts('Soft Credit For'), + 'dbAlias' => "NULL" ), ), - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'financial_type_id' => - array('title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'contribution_page_id' => - array('title' => ts('Contribution Page'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionPage(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'payment_instrument_id' => - array('title' => ts('Payment Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), - 'type' => CRM_Utils_Type::T_INT, + 'filters' => array( + 'contribution_or_soft' => array( + 'title' => ts('Contribution OR Soft Credit?'), + 'clause' => "(1)", + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'type' => CRM_Utils_Type::T_STRING, + 'options' => array( + 'both' => ts('Both'), + 'contributions_only' => ts('Contributions Only'), + 'soft_credits_only' => ts('Soft Credits Only'), + ), + ), + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'contribution_page_id' => array( + 'title' => ts('Contribution Page'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionPage(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + 'type' => CRM_Utils_Type::T_INT, + ), + 'total_amount' => array('title' => ts('Contribution Amount')), ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - 'type' => CRM_Utils_Type::T_INT, + 'order_bys' => array( + 'financial_type_id' => array('title' => ts('Financial Type')), + 'contribution_status_id' => array('title' => ts('Contribution Status')), + 'payment_instrument_id' => array('title' => ts('Payment Instrument')), + 'receive_date' => array('title' => ts('Receive Date')), ), - 'total_amount' => - array('title' => ts('Contribution Amount')), + 'grouping' => 'contri-fields', ), - 'order_bys' => array( - 'financial_type_id' => array('title' => ts('Financial Type')), - 'contribution_status_id' => array('title' => ts('Contribution Status')), - 'payment_instrument_id' => array('title' => ts('Payment Instrument')), - 'receive_date' => array('title' => ts('Receive Date')), - ), - 'grouping' => 'contri-fields', - ), - 'civicrm_contribution_soft' => - array( - 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => - array ( - 'soft_credit_type_id' => array('title' => ts('Soft Credit Type')), - ), - 'filters' => - array( - 'soft_credit_type_id' => - array('title' => 'Soft Credit Type', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, + 'civicrm_contribution_soft' => array( + 'dao' => 'CRM_Contribute_DAO_ContributionSoft', + 'fields' => array( + 'soft_credit_type_id' => array('title' => ts('Soft Credit Type')), + ), + 'filters' => array( + 'soft_credit_type_id' => array( + 'title' => 'Soft Credit Type', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), ), ), - ), - 'civicrm_contribution_ordinality' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'alias' => 'cordinality', - 'filters' => - array( - 'ordinality' => - array('title' => ts('Contribution Ordinality'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array( - 0 => 'First by Contributor', - 1 => 'Second or Later by Contributor', - ), - 'type' => CRM_Utils_Type::T_INT, + 'civicrm_contribution_ordinality' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'alias' => 'cordinality', + 'filters' => array( + 'ordinality' => array( + 'title' => ts('Contribution Ordinality'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => array( + 0 => 'First by Contributor', + 1 => 'Second or Later by Contributor', + ), + 'type' => CRM_Utils_Type::T_INT, + ), ), ), - ), - 'civicrm_note' => - array( - 'dao' => 'CRM_Core_DAO_Note', - 'fields' => - array( - 'contribution_note' => - array( - 'name' => 'note', - 'title' => ts('Contribution Note'), + 'civicrm_note' => array( + 'dao' => 'CRM_Core_DAO_Note', + 'fields' => array( + 'contribution_note' => array( + 'name' => 'note', + 'title' => ts('Contribution Note'), + ), ), - ), - 'filters' => - array( - 'note' => - array( - 'name' => 'note', - 'title' => ts('Contribution Note'), - 'operator' => 'like', - 'type' => CRM_Utils_Type::T_STRING, + 'filters' => array( + 'note' => array( + 'name' => 'note', + 'title' => ts('Contribution Note'), + 'operator' => 'like', + 'type' => CRM_Utils_Type::T_STRING, + ), ), ), - ), - ) + $this->addAddressFields(FALSE); + ) + $this->addAddressFields(FALSE); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -333,13 +315,14 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { ); } - // If we have active campaigns add those elements to both the fields and filters + // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array( 'title' => ts('Campaign'), 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -369,7 +352,9 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { // please note this will just add the order-by columns to select query, and not display in column-headers. // This is a solution to not throw fatal errors when there is a column in order-by, not present in select/display columns. foreach ($this->_orderByFields as $orderBy) { - if (!array_key_exists($orderBy['name'], $this->_params['fields']) && empty($orderBy['section'])) { + if (!array_key_exists($orderBy['name'], $this->_params['fields']) && + empty($orderBy['section']) + ) { $this->_select .= ", {$orderBy['dbAlias']} as {$orderBy['tplField']}"; } } @@ -384,11 +369,15 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { 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 (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'both') { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'both' + ) { $this->_from .= "\n LEFT JOIN civicrm_contribution_soft contribution_soft_civireport ON contribution_soft_civireport.contribution_id = {$this->_aliases['civicrm_contribution']}.id"; } - elseif (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'soft_credits_only') { + elseif (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'soft_credits_only' + ) { $this->_from .= "\n INNER JOIN civicrm_contribution_soft contribution_soft_civireport ON contribution_soft_civireport.contribution_id = {$this->_aliases['civicrm_contribution']}.id"; } @@ -413,7 +402,10 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { $this->addPhoneFromClause(); - if ($this->_addressField OR (!empty($this->_params['state_province_id_value']) OR !empty($this->_params['country_id_value']))) { + if ($this->_addressField OR + (!empty($this->_params['state_province_id_value']) OR + !empty($this->_params['country_id_value'])) + ) { $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND @@ -427,15 +419,19 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { {$this->_aliases['civicrm_email']}.is_primary = 1\n"; } // include contribution note - if (!empty($this->_params['fields']['contribution_note']) || !empty($this->_params['note_value'])) { - $this->_from.= " + if (!empty($this->_params['fields']['contribution_note']) || + !empty($this->_params['note_value']) + ) { + $this->_from .= " LEFT JOIN civicrm_note {$this->_aliases['civicrm_note']} ON ( {$this->_aliases['civicrm_note']}.entity_table = 'civicrm_contribution' AND {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_note']}.entity_id )"; } //for contribution batches if ($this->_allBatches && - (!empty($this->_params['fields']['batch_id']) || !empty($this->_params['bid_value']))) { + (!empty($this->_params['fields']['batch_id']) || + !empty($this->_params['bid_value'])) + ) { $this->_from .= " LEFT JOIN civicrm_entity_financial_trxn tx ON (tx.entity_id = {$this->_aliases['civicrm_contribution']}.id AND tx.entity_table = 'civicrm_contribution') @@ -474,8 +470,10 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)." (".$dao->count.")"; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $totalAmount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . " (" . + $dao->count . ")"; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } $statistics['counts']['amount'] = array( @@ -494,9 +492,12 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { ); // Stats for soft credits - if ($this->_softFrom && CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) != 'contributions_only') { + if ($this->_softFrom && + CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) != + 'contributions_only' + ) { $totalAmount = $average = array(); - $count = 0; + $count = 0; $select = " SELECT COUNT(contribution_soft_civireport.amount ) as count, SUM(contribution_soft_civireport.amount ) as amount, @@ -508,8 +509,10 @@ SELECT COUNT(contribution_soft_civireport.amount ) as count, GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)." (".$dao->count.")"; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $totalAmount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . " (" . + $dao->count . ")"; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } $statistics['counts']['softamount'] = array( @@ -537,7 +540,10 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $this->beginPostProcess(); - if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only' && !empty($this->_params['fields']['soft_credit_type_id'])) { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'contributions_only' && + !empty($this->_params['fields']['soft_credit_type_id']) + ) { unset($this->_params['fields']['soft_credit_type_id']); if (!empty($this->_params['soft_credit_type_id_value'])) { $this->_params['soft_credit_type_id_value'] = array(); @@ -546,7 +552,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; // 1. use main contribution query to build temp table 1 $sql = $this->buildQuery(); - $tempQuery = 'CREATE TEMPORARY TABLE civireport_contribution_detail_temp1 AS ' . $sql; + $tempQuery = + 'CREATE TEMPORARY TABLE civireport_contribution_detail_temp1 AS ' . $sql; CRM_Core_DAO::executeQuery($tempQuery); $this->setPager(); @@ -560,9 +567,12 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $select = str_ireplace("'Contribution' as", "'Soft Credit' as", $select); // we inner join with temp1 to restrict soft contributions to those in temp1 table $sql = "{$select} {$this->_from} {$this->_where} {$this->_groupBy}"; - $tempQuery = 'CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS ' . $sql; + $tempQuery = + 'CREATE TEMPORARY TABLE civireport_contribution_detail_temp2 AS ' . $sql; CRM_Core_DAO::executeQuery($tempQuery); - if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'soft_credits_only') { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'soft_credits_only' + ) { // revise pager : prev, next based on soft-credits only $this->setPager(); } @@ -578,11 +588,17 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $this->customDataFrom(); // 3. Decide where to populate temp3 table from - if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only') { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'contributions_only' + ) { $tempQuery = "(SELECT * FROM civireport_contribution_detail_temp1)"; - } else if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'soft_credits_only') { + } + else if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'soft_credits_only' + ) { $tempQuery = "(SELECT * FROM civireport_contribution_detail_temp2)"; - } else { + } + else { $tempQuery = " (SELECT * FROM civireport_contribution_detail_temp1) UNION ALL @@ -602,12 +618,13 @@ UNION ALL list($alias, $rest) = explode('.', $clause); $orderClause[] = $aliases[$alias] . "_" . $rest; } - $orderBy = (!empty($orderClause)) ? "ORDER BY " . implode(', ', $orderClause) : ''; + $orderBy = (!empty($orderClause)) ? + "ORDER BY " . implode(', ', $orderClause) : ''; } // 6. show result set from temp table 3 $rows = array(); - $sql = "SELECT * FROM civireport_contribution_detail_temp3 {$orderBy}"; + $sql = "SELECT * FROM civireport_contribution_detail_temp3 {$orderBy}"; $this->buildRows($sql, $rows); // format result set. @@ -625,13 +642,13 @@ UNION ALL */ function alterDisplay(&$rows) { // custom code to alter rows - $checkList = array(); - $entryFound = FALSE; - $display_flag = $prev_cid = $cid = 0; - $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); + $checkList = array(); + $entryFound = FALSE; + $display_flag = $prev_cid = $cid = 0; + $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); - $contributionPages = CRM_Contribute_PseudoConstant::contributionPage(); + $contributionPages = CRM_Contribute_PseudoConstant::contributionPage(); foreach ($rows as $rowNum => $row) { if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') { @@ -655,7 +672,9 @@ UNION ALL if ($display_flag) { foreach ($row as $colName => $colVal) { // Hide repeats in no-repeat columns, but not if the field's a section header - if (in_array($colName, $this->_noRepeats) && !array_key_exists($colName, $this->_sections)) { + if (in_array($colName, $this->_noRepeats) && + !array_key_exists($colName, $this->_sections) + ) { unset($rows[$rowNum][$colName]); } } @@ -665,12 +684,15 @@ UNION ALL } } - if (CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) == 'Contribution') { + if (CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) == + 'Contribution' + ) { unset($rows[$rowNum]['civicrm_contribution_soft_soft_credit_type_id']); } // convert donor sort name to link - if (array_key_exists('civicrm_contact_sort_name', $row) && !empty($rows[$rowNum]['civicrm_contact_sort_name']) && + if (array_key_exists('civicrm_contact_sort_name', $row) && + !empty($rows[$rowNum]['civicrm_contact_sort_name']) && array_key_exists('civicrm_contact_id', $row) ) { $url = CRM_Utils_System::url("civicrm/contact/view", @@ -709,7 +731,9 @@ UNION ALL CRM_Core_Permission::check('access CiviContribute') ) { $url = CRM_Utils_System::url("civicrm/contact/view/contribution", - "reset=1&id=" . $row['civicrm_contribution_contribution_id'] . "&cid=" . $row['civicrm_contact_id'] . "&action=view&context=contribution&selectedChild=contribute", + "reset=1&id=" . $row['civicrm_contribution_contribution_id'] . + "&cid=" . $row['civicrm_contact_id'] . + "&action=view&context=contribution&selectedChild=contribute", $this->_absoluteUrl ); $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url; @@ -727,37 +751,43 @@ UNION ALL // soft credits if (array_key_exists('civicrm_contribution_soft_credits', $row) && - 'Contribution' == CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) && + 'Contribution' == + CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) && array_key_exists('civicrm_contribution_contribution_id', $row) ) { $query = " SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount_sum, civicrm_contribution_currency FROM civireport_contribution_detail_temp2 WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}"; - $dao = CRM_Core_DAO::executeQuery($query); + $dao = CRM_Core_DAO::executeQuery($query); $string = ''; $separator = ($this->_outputMode !== 'csv') ? "
" : ' '; while ($dao->fetch()) { - $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $dao->civicrm_contact_id); - $string = $string . ($string ? $separator : '') . "{$dao->civicrm_contact_sort_name} " . + $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . + $dao->civicrm_contact_id); + $string = $string . ($string ? $separator : '') . + "{$dao->civicrm_contact_sort_name} " . CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->civicrm_contribution_currency); } $rows[$rowNum]['civicrm_contribution_soft_credits'] = $string; } if (array_key_exists('civicrm_contribution_soft_credit_for', $row) && - 'Soft Credit' == CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) && + 'Soft Credit' == + CRM_Utils_Array::value('civicrm_contribution_contribution_or_soft', $rows[$rowNum]) && array_key_exists('civicrm_contribution_contribution_id', $row) ) { $query = " SELECT civicrm_contact_id, civicrm_contact_sort_name FROM civireport_contribution_detail_temp1 WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}"; - $dao = CRM_Core_DAO::executeQuery($query); + $dao = CRM_Core_DAO::executeQuery($query); $string = ''; while ($dao->fetch()) { - $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $dao->civicrm_contact_id); - $string = $string . "\n{$dao->civicrm_contact_sort_name}"; + $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . + $dao->civicrm_contact_id); + $string = $string . + "\n{$dao->civicrm_contact_sort_name}"; } $rows[$rowNum]['civicrm_contribution_soft_credit_for'] = $string; } @@ -779,7 +809,7 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu } } - function sectionTotals( ) { + function sectionTotals() { // Reports using order_bys with sections must populate $this->_selectAliases in select() method. if (empty($this->_selectAliases)) { @@ -788,7 +818,7 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu if (!empty($this->_sections)) { // build the query with no LIMIT clause - $select = str_ireplace( 'SELECT SQL_CALC_FOUND_ROWS ', 'SELECT ', $this->_select ); + $select = str_ireplace('SELECT SQL_CALC_FOUND_ROWS ', 'SELECT ', $this->_select); $sql = "{$select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy}"; // pull section aliases out of $this->_sections @@ -806,14 +836,18 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu $addtotals = ''; - if (array_search("civicrm_contribution_total_amount_sum", $this->_selectAliases) !== FALSE) { + if (array_search("civicrm_contribution_total_amount_sum", $this->_selectAliases) !== + FALSE + ) { $addtotals = ", sum(civicrm_contribution_total_amount_sum) as sumcontribs"; $showsumcontribs = TRUE; } $query = "select " . implode(", ", $ifnulls) - ."$addtotals, count(*) as ct from civireport_contribution_detail_temp3 group by ". implode(", ", $sectionAliases); + . + "$addtotals, count(*) as ct from civireport_contribution_detail_temp3 group by " . + implode(", ", $sectionAliases); // initialize array of total counts $sumcontribs = $totals = array(); $dao = CRM_Core_DAO::executeQuery($query); @@ -834,13 +868,17 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu if ($i == $aliasCount) { // the last alias is the lowest-level section header; use count as-is $totals[$key] = $dao->ct; - if ($showsumcontribs) { $sumcontribs[$key] = $dao->sumcontribs; } + if ($showsumcontribs) { + $sumcontribs[$key] = $dao->sumcontribs; + } } else { // other aliases are higher level; roll count into their total - $totals[$key] = (array_key_exists($key, $totals)) ? $totals[$key] + $dao->ct : $dao->ct; + $totals[$key] = (array_key_exists($key, $totals)) ? + $totals[$key] + $dao->ct : $dao->ct; if ($showsumcontribs) { - $sumcontribs[$key] = array_key_exists($key, $sumcontribs) ? $sumcontribs[$key] + $dao->sumcontribs : $dao->sumcontribs; + $sumcontribs[$key] = array_key_exists($key, $sumcontribs) ? + $sumcontribs[$key] + $dao->sumcontribs : $dao->sumcontribs; } } } @@ -850,9 +888,14 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu // ts exception to avoid having ts("%1 %2: %3") $title = '%1 contributions / soft-credits: %2'; - if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only') { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'contributions_only' + ) { $title = '%1 contributions: %2'; - } else if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'soft_credits_only') { + } + else if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == + 'soft_credits_only' + ) { $title = '%1 soft-credits: %2'; } foreach ($totals as $key => $total) { diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index a18fbbb212..b10f6f3b00 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -59,9 +59,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { */ function __construct() { $yearsInPast = 4; - $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, 0); - $count = $date['maxYear']; - $optionYear = array('' => ts('- select -')); + $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, 0); + $count = $date['maxYear']; + $optionYear = array('' => ts('- select -')); $this->_yearStatisticsFrom = $date['minYear']; $this->_yearStatisticsTo = $date['maxYear']; @@ -83,157 +83,135 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), - 'default' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'default' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'id' => array( + 'no_display' => TRUE, + 'default' => TRUE, + 'required' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), ), - 'id' => - array( - 'no_display' => TRUE, - 'default' => TRUE, - 'required' => TRUE, - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), + 'grouping' => 'contact-fields', + 'filters' => array( + 'sort_name' => array('title' => ts('Contact Name')), + 'id' => array( + 'title' => ts('Contact ID'), + 'no_display' => TRUE, + ), ), ), - 'grouping' => 'contact-fields', - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name')), - 'id' => - array('title' => ts('Contact ID'), - 'no_display' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'no_repeat' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), - 'no_repeat' => TRUE, + ) + $this->addAddressFields(FALSE, FALSE, FALSE, array()) + array( + 'civicrm_relationship' => array( + 'dao' => 'CRM_Contact_DAO_Relationship', + 'fields' => array( + 'relationship_type_id' => array( + 'title' => ts('Relationship Type'), + 'default' => TRUE, + ), + 'contact_id_a' => array('no_display' => TRUE), + 'contact_id_b' => array('no_display' => TRUE), ), - ), - 'grouping' => 'contact-fields', - ), - ) + $this->addAddressFields(FALSE, FALSE, FALSE, array( - )) + array('civicrm_relationship' => - array( - 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => - array( - 'relationship_type_id' => - array('title' => ts('Relationship Type'), - 'default' => TRUE, - ), - 'contact_id_a' => - array('no_display' => TRUE), - 'contact_id_b' => - array('no_display' => TRUE), - ), - 'filters' => - array( - 'relationship_type_id' => - array('title' => ts('Relationship Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $relationTypeOp, - 'type' => CRM_Utils_Type::T_STRING, + 'filters' => array( + 'relationship_type_id' => array( + 'title' => ts('Relationship Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $relationTypeOp, + 'type' => CRM_Utils_Type::T_STRING, + ), ), ), - ), - ) + array( - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'total_amount' => - array('title' => ts('Amount Statistics'), - 'default' => TRUE, - 'required' => TRUE, - 'no_display' => TRUE, - 'statistics' => - array('sum' => ts('Aggregate Amount')), - ), - 'receive_date' => - array( - 'required' => TRUE, - 'default' => TRUE, - 'no_display' => TRUE, - ), - ), - 'grouping' => 'contri-fields', - 'filters' => - array( - 'this_year' => - array( - 'title' => ts('This Year'), - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => $optionYear, - 'default' => '', - ), - 'other_year' => - array( - 'title' => ts('Other Years'), - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => $optionYear, - 'default' => '', + ) + array( + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'total_amount' => array( + 'title' => ts('Amount Statistics'), + 'default' => TRUE, + 'required' => TRUE, + 'no_display' => TRUE, + 'statistics' => array('sum' => ts('Aggregate Amount')), + ), + 'receive_date' => array( + 'required' => TRUE, + 'default' => TRUE, + 'no_display' => TRUE, + ), ), - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - 'financial_type_id' => array( - 'title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'total_amount' => - array('title' => ts('Contribution Amount'), - ), - 'total_sum' => - array('title' => ts('Aggregate Amount'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_sum', - 'having' => TRUE, + 'grouping' => 'contri-fields', + 'filters' => array( + 'this_year' => array( + 'title' => ts('This Year'), + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => $optionYear, + 'default' => '', + ), + 'other_year' => array( + 'title' => ts('Other Years'), + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => $optionYear, + 'default' => '', + ), + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'total_amount' => array( + 'title' => ts('Contribution Amount'), + ), + 'total_sum' => array( + 'title' => ts('Aggregate Amount'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_sum', + 'having' => TRUE, + ), ), ), - ), - ); + ); - $this->_columns['civicrm_contribution']['fields']['civicrm_upto_' . $this->_yearStatisticsFrom] = array('title' => ts('Up To %1 Donation', array(1 => $this->_yearStatisticsFrom)), + $this->_columns['civicrm_contribution']['fields']['civicrm_upto_' . + $this->_yearStatisticsFrom] = array( + 'title' => ts('Up To %1 Donation', array(1 => $this->_yearStatisticsFrom)), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, @@ -242,7 +220,8 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $yearConter = $this->_yearStatisticsFrom; $yearConter++; while ($yearConter <= $this->_yearStatisticsTo) { - $this->_columns['civicrm_contribution']['fields'][$yearConter] = array('title' => ts('%1 Donation', array(1 => $yearConter)), + $this->_columns['civicrm_contribution']['fields'][$yearConter] = array( + 'title' => ts('%1 Donation', array(1 => $yearConter)), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, @@ -250,7 +229,8 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $yearConter++; } - $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = array('title' => ts('Aggregate Amount'), + $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = array( + 'title' => ts('Aggregate Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, ); @@ -272,7 +252,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } @@ -295,12 +277,18 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { continue; } 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}"; - } + 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}"; @@ -364,10 +352,13 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $clause = NULL; if ($fieldName == 'this_year' || $fieldName == 'other_year') { continue; - }elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { + } + elseif (CRM_Utils_Array::value('type', $field) & + CRM_Utils_Type::T_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } @@ -422,7 +413,8 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } if (!empty($relationshipWhere)) { - $this->_relationshipWhere = ' AND ' . implode(' AND ', $relationshipWhere); + $this->_relationshipWhere = ' AND ' . + implode(' AND ', $relationshipWhere); } } @@ -459,12 +451,14 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $count++; } } - $statistics['counts']['rowCount'] = array('title' => ts('Primary Contact(s) Listed'), + $statistics['counts']['rowCount'] = array( + 'title' => ts('Primary Contact(s) Listed'), 'value' => $count, ); if ($this->_rowsFound && ($this->_rowsFound > $count)) { - $statistics['counts']['rowsFound'] = array('title' => ts('Total Primary Contact(s)'), + $statistics['counts']['rowsFound'] = array( + 'title' => ts('Total Primary Contact(s)'), 'value' => $this->_rowsFound, ); } @@ -481,7 +475,8 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { */ static function formRule($fields, $files, $self) { $errors = array(); - if (!empty($fields['this_year_value']) && !empty($fields['other_year_value']) && + 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."); @@ -536,12 +531,14 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $addWhere = ''; 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 ) "; + (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 (!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 ) "; + (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}"; @@ -570,9 +567,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $relatedContributions = $this->buildContributionRows($relatedContactIds); - $summaryYears = array(); + $summaryYears = array(); $summaryYears[] = "civicrm_upto_{$this->_yearStatisticsFrom}"; - $yearConter = $this->_yearStatisticsFrom; + $yearConter = $this->_yearStatisticsFrom; $yearConter++; while ($yearConter <= $this->_yearStatisticsTo) { $summaryYears[] = $yearConter; @@ -629,11 +626,14 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { return $rows; } - $sqlContribution = "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . implode(',', $contactIds) . ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; + $sqlContribution = + "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . + implode(',', $contactIds) . + ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; - $dao = CRM_Core_DAO::executeQuery($sqlContribution); + $dao = CRM_Core_DAO::executeQuery($sqlContribution); $contributionSum = 0; - $yearcal = array(); + $yearcal = array(); while ($dao->fetch()) { if (!$dao->civicrm_contact_id) { continue; @@ -645,7 +645,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } } if ($dao->civicrm_contribution_receive_date) { - if ($dao->civicrm_contribution_receive_date > $this->_yearStatisticsFrom) { + if ($dao->civicrm_contribution_receive_date > + $this->_yearStatisticsFrom + ) { $rows[$dao->civicrm_contact_id][$dao->civicrm_contribution_receive_date] = $dao->civicrm_contribution_total_amount; } else { @@ -682,7 +684,10 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { if (!empty($this->_relationshipColumns)) { $addRelSelect = ', ' . implode(', ', $this->_relationshipColumns); } - $sqlRelationship = "SELECT {$this->_aliases['civicrm_relationship']}.relationship_type_id as relationship_type_id, {$this->_aliases['civicrm_relationship']}.contact_id_a as contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b as contact_id_b {$addRelSelect} FROM civicrm_contact {$relContactAlias} {$this->_relationshipFrom} WHERE {$relContactAlias}.id IN (" . implode(',', $contactIds) . ") AND {$this->_aliases['civicrm_relationship']}.is_active = 1 {$this->_relationshipWhere} GROUP BY {$this->_aliases['civicrm_relationship']}.contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b"; + $sqlRelationship = + "SELECT {$this->_aliases['civicrm_relationship']}.relationship_type_id as relationship_type_id, {$this->_aliases['civicrm_relationship']}.contact_id_a as contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b as contact_id_b {$addRelSelect} FROM civicrm_contact {$relContactAlias} {$this->_relationshipFrom} WHERE {$relContactAlias}.id IN (" . + implode(',', $contactIds) . + ") AND {$this->_aliases['civicrm_relationship']}.is_active = 1 {$this->_relationshipWhere} GROUP BY {$this->_aliases['civicrm_relationship']}.contact_id_a, {$this->_aliases['civicrm_relationship']}.contact_id_b"; $relationshipTypes = CRM_Core_PseudoConstant::relationshipType(); $dao = CRM_Core_DAO::executeQuery($sqlRelationship); @@ -717,7 +722,10 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { */ 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 array( + 'calendar' => ts('Is Calendar Year'), + 'fiscal' => ts('Fiscal Year Starting') + ); } return parent::getOperationPair($type, $fieldName); } @@ -758,7 +766,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } // Convert Display name into link - if (!empty($row['civicrm_contact_sort_name']) && !empty($row['civicrm_contact_id'])) { + 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 @@ -768,5 +778,5 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } } } - } +} diff --git a/CRM/Report/Form/Contribute/HouseholdSummary.php b/CRM/Report/Form/Contribute/HouseholdSummary.php index 555b8e4620..351215a14f 100644 --- a/CRM/Report/Form/Contribute/HouseholdSummary.php +++ b/CRM/Report/Form/Contribute/HouseholdSummary.php @@ -64,11 +64,10 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { 'civicrm_contact_household' => array( 'dao' => 'CRM_Contact_DAO_Contact', 'fields' => array( - 'household_name' => - array( - 'title' => ts('Household Name'), - 'required' => TRUE, - ), + 'household_name' => array( + 'title' => ts('Household Name'), + 'required' => TRUE, + ), 'id' => array( 'no_display' => TRUE, 'required' => TRUE, @@ -210,7 +209,9 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } @@ -283,7 +284,9 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); if ($op) { if ($fieldName == 'relationship_type_id') { - $clause = "{$this->_aliases['civicrm_relationship']}.relationship_type_id=" . $this->relationshipId; + $clause = + "{$this->_aliases['civicrm_relationship']}.relationship_type_id=" . + $this->relationshipId; } else { $clause = $this->whereClause($field, @@ -348,7 +351,10 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { function postProcess() { $this->beginPostProcess(); - $this->buildACLClause(array($this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_household'])); + $this->buildACLClause(array( + $this->_aliases['civicrm_contact'], + $this->_aliases['civicrm_contact_household'] + )); $sql = $this->buildQuery(TRUE); $rows = array(); @@ -416,13 +422,16 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { //replace retionship id by relationship name if (array_key_exists('civicrm_relationship_relationship_type_id', $row)) { if ($value = $row['civicrm_relationship_relationship_type_id']) { - $rows[$rowNum]['civicrm_relationship_relationship_type_id'] = $this->relationTypes[$value . '_' . $type]; + $rows[$rowNum]['civicrm_relationship_relationship_type_id'] = $this->relationTypes[ + $value . '_' . $type]; $entryFound = TRUE; } } //remove duplicate Organization names - if (array_key_exists('civicrm_contact_household_household_name', $row) && $this->_outputMode != 'csv') { + if (array_key_exists('civicrm_contact_household_household_name', $row) && + $this->_outputMode != 'csv' + ) { if ($value = $row['civicrm_contact_household_household_name']) { if ($rowNum == 0) { $priviousHousehold = $value; @@ -448,14 +457,18 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { ); $rows[$rowNum]['civicrm_contact_household_household_name'] = - "" . $value . ''; + "" . $value . + ''; } $entryFound = TRUE; } } //remove duplicate Contact names and relationship type - if (array_key_exists('civicrm_contact_id', $row) && $this->_outputMode != 'csv') { + if (array_key_exists('civicrm_contact_id', $row) && + $this->_outputMode != 'csv' + ) { if ($value = $row['civicrm_contact_id']) { if ($rowNum == 0) { $priviousContact = $value; @@ -526,7 +539,8 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { CRM_Core_Permission::check('access CiviContribute') ) { $url = CRM_Utils_System::url("civicrm/contact/view/contribution", - "reset=1&id=" . $row['civicrm_contribution_id'] . "&cid=" . $row['civicrm_contact_id'] . + "reset=1&id=" . $row['civicrm_contribution_id'] . "&cid=" . + $row['civicrm_contact_id'] . "&action=view&context=contribution&selectedChild=contribute", $this->_absoluteUrl ); diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 82fbe98e40..5b18ae58ab 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -53,10 +53,10 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { * */ function __construct() { - $yearsInPast = 10; + $yearsInPast = 10; $yearsInFuture = 1; - $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); - $count = $date['maxYear']; + $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); + $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; @@ -72,115 +72,102 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'grouping' => 'contact-field', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'default' => TRUE, - 'required' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'grouping' => 'contact-field', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'default' => TRUE, + 'required' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), ), - 'first_name' => array( - 'title' => ts('First Name'), - ), - 'last_name' => array( - 'title' => ts('Last Name'), - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'operator' => 'like', + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'operator' => 'like', + ), ), ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'grouping' => 'contact-field', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'default' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'grouping' => 'contact-field', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'default' => TRUE, + ), ), ), - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'grouping' => 'contact-field', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), - 'default' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'grouping' => 'contact-field', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'default' => TRUE, + ), ), ), - ), - ) - + $this->addAddressFields() - + array( - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contact_id' => - array('title' => ts('contactId'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, + ) + + $this->addAddressFields() + + array( + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'contact_id' => array( + 'title' => ts('contactId'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'total_amount' => array( + 'title' => ts('Total Amount'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'receive_date' => array( + 'title' => ts('Year'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), ), - 'total_amount' => - array('title' => ts('Total Amount'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'receive_date' => - array('title' => ts('Year'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, + 'filters' => array( + 'yid' => array( + 'name' => 'receive_date', + 'title' => ts('This Year'), + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => $optionYear, + 'default' => date('Y'), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array('1'), + ), ), ), - 'filters' => - array( - 'yid' => - array( - 'name' => 'receive_date', - 'title' => ts('This Year'), - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => $optionYear, - 'default' => date('Y'), - ), - 'financial_type_id' => array( - 'title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array('1'), - ), - ), - ), - ); + ); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { @@ -188,7 +175,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { 'title' => ts('Campaign'), 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -215,7 +203,9 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($fieldName == 'total_amount') { $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}"; @@ -226,7 +216,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $this->_columnHeaders["civicrm_life_time_total"]['title'] = 'LifeTime';; } elseif ($fieldName == 'receive_date') { - $select[] = self::fiscalYearOffset($field['dbAlias']) . " as {$tableName}_{$fieldName} "; + $select[] = self::fiscalYearOffset($field['dbAlias']) . + " as {$tableName}_{$fieldName} "; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName} "; @@ -270,9 +261,9 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { function where() { $this->_statusClause = ""; - $clauses = array($this->_aliases['civicrm_contribution'] . '.is_test = 0'); - $current_year = $this->_params['yid_value']; - $previous_year = $current_year - 1; + $clauses = array($this->_aliases['civicrm_contribution'] . '.is_test = 0'); + $current_year = $this->_params['yid_value']; + $previous_year = $current_year - 1; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -281,13 +272,17 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { if ($fieldName == 'yid') { $clause = "contribution_civireport.contact_id NOT IN (SELECT distinct contri.contact_id FROM civicrm_contribution contri - WHERE contri.is_test = 0 AND " . self::fiscalYearOffset('contri.receive_date') . " = $current_year) AND contribution_civireport.contact_id IN (SELECT distinct contri.contact_id FROM civicrm_contribution contri - WHERE " . self::fiscalYearOffset('contri.receive_date') . " = $previous_year AND contri.is_test = 0)"; + WHERE contri.is_test = 0 AND " . + self::fiscalYearOffset('contri.receive_date') . " = $current_year) AND contribution_civireport.contact_id IN (SELECT distinct contri.contact_id FROM civicrm_contribution contri + WHERE " . self::fiscalYearOffset('contri.receive_date') . + " = $previous_year AND contri.is_test = 0)"; } - elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { + elseif (CRM_Utils_Array::value('type', $field) & + CRM_Utils_Type::T_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -302,7 +297,9 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params) ); - if (($fieldName == 'contribution_status_id' || $fieldName == 'financial_type_id') && !empty($clause)) { + if (($fieldName == 'contribution_status_id' || + $fieldName == 'financial_type_id') && !empty($clause) + ) { $this->_statusClause .= " AND " . $clause; } } @@ -323,7 +320,10 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } function groupBy() { - $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, " . self::fiscalYearOffset($this->_aliases['civicrm_contribution'] . '.receive_date') . " WITH ROLLUP"; + $this->_groupBy = + "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, " . + self::fiscalYearOffset($this->_aliases['civicrm_contribution'] . + '.receive_date') . " WITH ROLLUP"; $this->assign('chartSupported', TRUE); } @@ -384,11 +384,14 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; } else { - $sql = "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . implode(',', $contactIds) . ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; + $sql = + "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . + implode(',', $contactIds) . + ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; } - $dao = CRM_Core_DAO::executeQuery($sql); - $current_year = $this->_params['yid_value']; + $dao = CRM_Core_DAO::executeQuery($sql); + $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; while ($dao->fetch()) { @@ -431,8 +434,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { function buildChart(&$rows) { $graphRows = array(); - $count = 0; - $display = array(); + $count = 0; + $display = array(); $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; @@ -440,13 +443,16 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $interval['life_time'] = 'Life Time'; foreach ($rows as $key => $row) { - $display['life_time'] = CRM_Utils_Array::value('life_time', $display) + $row['civicrm_life_time_total']; - $display[$previous_year] = CRM_Utils_Array::value($previous_year, $display) + $row[$previous_year]; + $display['life_time'] = CRM_Utils_Array::value('life_time', $display) + + $row['civicrm_life_time_total']; + $display[$previous_year] = + CRM_Utils_Array::value($previous_year, $display) + $row[$previous_year]; } - $config = CRM_Core_Config::Singleton(); + $config = CRM_Core_Config::Singleton(); $graphRows['value'] = $display; - $chartInfo = array('legend' => ts('Lybunt Report'), + $chartInfo = array( + 'legend' => ts('Lybunt Report'), 'xname' => ts('Year'), 'yname' => ts('Amount (%1)', array(1 => $config->defaultCurrency)), ); @@ -470,7 +476,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { array_key_exists('civicrm_contribution_contact_id', $row) ) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', - 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contribution_contact_id'], + 'reset=1&force=1&id_op=eq&id_value=' . + $row['civicrm_contribution_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; @@ -505,7 +512,10 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { */ function getOperationPair($type = "string", $fieldName = NULL) { if ($fieldName == 'yid') { - return array('calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting')); + return array( + 'calendar' => ts('Is Calendar Year'), + 'fiscal' => ts('Fiscal Year Starting') + ); } return parent::getOperationPair($type, $fieldName); } diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index 9c8369d2df..caee0375ac 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -42,146 +42,128 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Supporter'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Supporter'), 'required' => TRUE, 'default' => TRUE, ), - 'id' => - array( + 'id' => array( 'required' => TRUE, 'no_display' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Supporter Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Supporter Contact Subtype'), ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Supporter Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Supporter Name'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', ), - 'id' => - array('title' => ts('Contact ID'), + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, ), ), 'grouping' => 'pcp-fields', ), - 'civicrm_contribution_page' => - array( + 'civicrm_contribution_page' => array( 'dao' => 'CRM_Contribute_DAO_ContributionPage', - 'fields' => - array( - 'page_title' => - array('title' => ts('Contribution Page Title'), + 'fields' => array( + 'page_title' => array( + 'title' => ts('Contribution Page Title'), 'name' => 'title', 'default' => TRUE, ), ), - 'filters' => - array( - 'page_title' => - array('title' => ts('Contribution Page Title'), + 'filters' => array( + 'page_title' => array( + 'title' => ts('Contribution Page Title'), 'name' => 'title', 'type' => CRM_Utils_Type::T_STRING, ), ), 'grouping' => 'pcp-fields', ), - 'civicrm_pcp' => - array( + 'civicrm_pcp' => array( 'dao' => 'CRM_PCP_DAO_PCP', - 'fields' => - array( - 'title' => - array('title' => ts('Personal Campaign Title'), + 'fields' => array( + 'title' => array( + 'title' => ts('Personal Campaign Title'), 'default' => TRUE, ), - 'goal_amount' => - array('title' => ts('Goal Amount'), + 'goal_amount' => array( + 'title' => ts('Goal Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, ), ), - 'filters' => - array( - 'title' => - array('title' => ts('Personal Campaign Title'), + 'filters' => array( + 'title' => array( + 'title' => ts('Personal Campaign Title'), 'type' => CRM_Utils_Type::T_STRING, ), ), 'grouping' => 'pcp-fields', ), - 'civicrm_contribution_soft' => - array( + 'civicrm_contribution_soft' => array( 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => - array( - 'amount_1' => - array('title' => ts('Committed Amount'), + 'fields' => array( + 'amount_1' => array( + 'title' => ts('Committed Amount'), 'name' => 'amount', 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, - 'statistics' => - array('sum' => ts('Committed Amount'), + 'statistics' => array( + 'sum' => ts('Committed Amount'), ), ), - 'amount_2' => - array('title' => ts('Amount Received'), + 'amount_2' => array( + 'title' => ts('Amount Received'), 'name' => 'amount', 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, // nice trick with dbAlias 'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))', ), - 'soft_id' => - array('title' => ts('Number of Donors'), + 'soft_id' => array( + 'title' => ts('Number of Donors'), 'name' => 'id', 'default' => TRUE, - 'statistics' => - array('count' => ts('Number of Donors'), + 'statistics' => array( + 'count' => ts('Number of Donors'), ), ), ), - 'filters' => - array( - 'amount_2' => - array('title' => ts('Amount Received'), + 'filters' => array( + 'amount_2' => array( + 'title' => ts('Amount Received'), 'type' => CRM_Utils_Type::T_MONEY, 'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))', ), ), 'grouping' => 'pcp-fields', ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contribution_id' => - array( + 'fields' => array( + 'contribution_id' => array( 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, ), - 'receive_date' => - array('title' => ts('Most Recent Contribution'), + 'receive_date' => array( + 'title' => ts('Most Recent Contribution'), 'default' => TRUE, - 'statistics' => - array('max' => ts('Most Recent Contribution'), + 'statistics' => array( + 'max' => ts('Most Recent Contribution'), ), ), ), @@ -231,9 +213,9 @@ LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page' if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); - $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); @@ -285,9 +267,10 @@ LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page' function statistics(&$rows) { $statistics = parent::statistics($rows); - $select = "SELECT SUM({$this->_aliases['civicrm_pcp']}.goal_amount) as goal_total, ". - "SUM({$this->_aliases['civicrm_contribution_soft']}.amount) as committed_total, ". - "COUNT({$this->_aliases['civicrm_contribution_soft']}.id) as donors_total, ". + $select = + "SELECT SUM({$this->_aliases['civicrm_pcp']}.goal_amount) as goal_total, " . + "SUM({$this->_aliases['civicrm_contribution_soft']}.amount) as committed_total, " . + "COUNT({$this->_aliases['civicrm_contribution_soft']}.id) as donors_total, " . "SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount)) AS received_total "; $sql = "{$select} {$this->_from} {$this->_where}"; $dao = CRM_Core_DAO::executeQuery($sql); diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index e10a830dc4..ea3a43f518 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -46,48 +46,38 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-fields', - 'fields' => - array( - 'sort_name' => - array( + 'fields' => array( + 'sort_name' => array( 'title' => ts('Contact Name'), 'no_repeat' => TRUE, 'default' => TRUE, ), - 'display_name' => - array( + 'display_name' => array( 'title' => ts('Display Name'), 'no_repeat' => TRUE, ), - 'addressee_display' => - array( + 'addressee_display' => array( 'title' => ts('Addressee Name'), 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), 'no_repeat' => TRUE, ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), 'no_repeat' => TRUE, ), ), - 'filters' => - array( - 'percentage_change' => - array( + 'filters' => array( + 'percentage_change' => array( 'title' => ts('Percentage Change'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, @@ -95,47 +85,37 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { 'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )', ), ), - 'group_bys' => - array( - 'id' => - array( + 'group_bys' => array( + 'id' => array( 'title' => ts('Contact'), 'default' => TRUE, ), ), ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array( + 'fields' => array( + 'email' => array( 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array( + 'fields' => array( + 'phone' => array( 'title' => ts('Phone'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => - array( + 'fields' => array( 'street_address' => array('title' => ts('Street Address')), 'supplemental_address_1' => array('title' => ts('Supplemental Address 1')), 'city' => array('title' => ts('City')), @@ -143,34 +123,29 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { 'state_province_id' => array('title' => ts('State/Province')), 'postal_code' => array('title' => ts('Postal Code')), ), - 'group_bys' => - array( + 'group_bys' => array( 'country_id' => array('title' => ts('Country')), - 'state_province_id' => array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), ), ), - 'civicrm_financial_type' => - array( + 'civicrm_financial_type' => array( 'dao' => 'CRM_Financial_DAO_FinancialType', 'fields' => array('financial_type' => array('title' => ts('Financial Type'))), - 'grouping' => 'contri-fields', - 'group_bys' => - array('financial_type' => - array( - 'name' => 'id', - 'title' => ts('Financial Type'), - ), + 'grouping' => 'contri-fields', + 'group_bys' => array( + 'financial_type' => array( + 'name' => 'id', + 'title' => ts('Financial Type'), + ), ), ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( + 'fields' => array( 'contribution_source' => NULL, - 'total_amount1' => - array( + 'total_amount1' => array( 'name' => 'total_amount', 'alias' => 'contribution1', 'title' => ts('Range One Stat'), @@ -181,8 +156,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { contribution_civireport1.total_amount_count as contribution1_total_amount_count, contribution_civireport1.total_amount_sum as contribution1_total_amount_sum', ), - 'total_amount2' => - array( + 'total_amount2' => array( 'name' => 'total_amount', 'alias' => 'contribution2', 'title' => ts('Range Two Stat'), @@ -195,46 +169,39 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum', ), ), 'grouping' => 'contri-fields', - 'filters' => - array( - 'receive_date1' => - array( + 'filters' => array( + 'receive_date1' => array( 'title' => ts('Initial Date Range'), 'default' => 'previous.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', ), - 'receive_date2' => - array( + 'receive_date2' => array( 'title' => ts('Second Date Range'), 'default' => 'this.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', ), - 'total_amount1' => - array( + 'total_amount1' => array( 'title' => ts('Range One Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'total_amount', ), - 'total_amount2' => - array( + 'total_amount2' => array( 'title' => ts('Range Two Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'total_amount', ), - 'financial_type_id' => - array( + 'financial_type_id' => array( 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), - 'contribution_status_id' => - array( + 'contribution_status_id' => array( 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), @@ -277,7 +244,9 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum', foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if (isset($field['clause'])) { $select[] = $field['clause']; @@ -309,7 +278,9 @@ contribution_civireport2.total_amount_sum as contribution2_total_amount_sum', */ function groupBy($tableCol = FALSE) { $this->_groupBy = ""; - if (!empty($this->_params['group_bys']) && is_array($this->_params['group_bys'])) { + if (!empty($this->_params['group_bys']) && + is_array($this->_params['group_bys']) + ) { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { @@ -353,7 +324,7 @@ LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} $from .= " INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']} ON {$this->_aliases['civicrm_address']}.contact_id = {$this->_aliases['civicrm_contact']}.id"; $fromAlias = $this->_aliases['civicrm_contact']; - $fromCol = "id"; + $fromCol = "id"; $contriCol = "contact_id"; } @@ -377,8 +348,8 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } @@ -418,7 +389,8 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution unset($clauses['receive_date1'], $clauses['total_amount1']); } - $whereClause = !empty($clauses) ? "WHERE " . implode(' AND ', $clauses) : ''; + $whereClause = !empty($clauses) ? + "WHERE " . implode(' AND ', $clauses) : ''; if ($replaceAliasWith) { $whereClause = str_replace($this->_aliases['civicrm_contribution'], $replaceAliasWith, $whereClause); @@ -435,7 +407,9 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution $clauses = array("atleast_one_amount" => $this->_amountClauseWithAND); foreach ($this->_columns as $tableName => $table) { - if (array_key_exists('filters', $table) && $tableName != 'civicrm_contribution') { + if (array_key_exists('filters', $table) && + $tableName != 'civicrm_contribution' + ) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); @@ -454,7 +428,8 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution } } - $this->_where = !empty($clauses) ? "WHERE " . implode(' AND ', $clauses) : ''; + $this->_where = !empty($clauses) ? + "WHERE " . implode(' AND ', $clauses) : ''; } /** @@ -506,8 +481,8 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution $errors['fields'] = ts('Please select at least one Group by field.'); } elseif ((array_key_exists('contribution_source', $fields['group_bys']) || - array_key_exists('contribution_type', $fields['group_bys']) - ) && + array_key_exists('contribution_type', $fields['group_bys']) + ) && (count($fields['group_bys']) > 1) ) { $errors['fields'] = ts('You can not use other Group by with Financial type or Contribution source.'); @@ -528,7 +503,10 @@ LEFT JOIN civicrm_temp_civireport_repeat2 {$this->_aliases['civicrm_contribution } if (!$found) { $erorrGrps = implode(',', $invlidGroups); - $tempErrors[] = ts("Do not select field %1 with Group by %2.", array(1 => $idMapping[$fld_id], 2 => $erorrGrps)); + $tempErrors[] = ts("Do not select field %1 with Group by %2.", array( + 1 => $idMapping[$fld_id], + 2 => $erorrGrps + )); } } } @@ -659,20 +637,26 @@ LEFT JOIN civicrm_temp_civireport_repeat2 $number_lapsed = 0; foreach ($contact_sums as $uid => $row) { - if ($row['contribution1_total_amount_sum'] && $row['contribution2_total_amount_sum']) { - $change = ($row['contribution1_total_amount_sum'] - $row['contribution2_total_amount_sum']); - if($change == 0) + if ($row['contribution1_total_amount_sum'] && + $row['contribution2_total_amount_sum'] + ) { + $change = ($row['contribution1_total_amount_sum'] - + $row['contribution2_total_amount_sum']); + if ($change == 0) { $number_maintained += 1; - elseif($change > 0) + } + elseif ($change > 0) { $number_upgraded += 1; - elseif($change < 0) + } + elseif ($change < 0) { $number_downgraded += 1; + } } elseif ($row['contribution1_total_amount_sum']) { - $number_new +=1; + $number_new += 1; } elseif ($row['contribution2_total_amount_sum']) { - $number_lapsed +=1; + $number_lapsed += 1; } } @@ -722,14 +706,18 @@ GROUP BY currency $count = $count2 = 0; while ($dao->fetch()) { if ($dao->amount) { - $amount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)."(".$dao->count.")"; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $amount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" . + $dao->count . ")"; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); } $count += $dao->count; if ($dao->amount2) { - $amount2[] = CRM_Utils_Money::format($dao->amount2, $dao->currency)."(".$dao->count.")"; - $average2[] = CRM_Utils_Money::format($dao->avg2, $dao->currency); + $amount2[] = + CRM_Utils_Money::format($dao->amount2, $dao->currency) . "(" . + $dao->count . ")"; + $average2[] = CRM_Utils_Money::format($dao->avg2, $dao->currency); } $count2 += $dao->count2; } @@ -842,9 +830,9 @@ currency varchar(3) $this->limit(); $count = 0; - $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_limit}"; - $dao = CRM_Core_DAO::executeQuery($sql); - $rows = array(); + $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_limit}"; + $dao = CRM_Core_DAO::executeQuery($sql); + $rows = array(); while ($dao->fetch()) { foreach ($this->_columnHeaders as $key => $value) { $rows[$count][$key] = $dao->$key; @@ -854,11 +842,13 @@ currency varchar(3) // FIXME: calculate % using query foreach ($rows as $uid => $row) { - if ($row['contribution1_total_amount_sum'] && $row['contribution2_total_amount_sum']) { + if ($row['contribution1_total_amount_sum'] && + $row['contribution2_total_amount_sum'] + ) { $rows[$uid]['change'] = number_format((($row['contribution2_total_amount_sum'] - - $row['contribution1_total_amount_sum'] - ) * 100) / - ($row['contribution1_total_amount_sum']), 2 + $row['contribution1_total_amount_sum'] + ) * 100) / + ($row['contribution1_total_amount_sum']), 2 ); } elseif ($row['contribution1_total_amount_sum']) { @@ -868,10 +858,14 @@ currency varchar(3) $rows[$uid]['change'] = ts('New Donor'); } if ($row['contribution1_total_amount_count']) { - $rows[$uid]['contribution1_total_amount_sum'] = $row['contribution1_total_amount_sum'] . " ({$row['contribution1_total_amount_count']})"; + $rows[$uid]['contribution1_total_amount_sum'] = + $row['contribution1_total_amount_sum'] . + " ({$row['contribution1_total_amount_count']})"; } if ($row['contribution2_total_amount_count']) { - $rows[$uid]['contribution2_total_amount_sum'] = $row['contribution2_total_amount_sum'] . " ({$row['contribution2_total_amount_count']})"; + $rows[$uid]['contribution2_total_amount_sum'] = + $row['contribution2_total_amount_sum'] . + " ({$row['contribution2_total_amount_count']})"; } } $this->_columnHeaders['change'] = array( @@ -897,7 +891,7 @@ currency varchar(3) $this->_columnHeaders['contribution1_total_amount_sum']['title'] = "$from1 -
$to1"; $this->_columnHeaders['contribution2_total_amount_sum']['title'] = "$from2 -
$to2"; unset($this->_columnHeaders['contribution1_total_amount_count'], - $this->_columnHeaders['contribution2_total_amount_count'] + $this->_columnHeaders['contribution2_total_amount_count'] ); $this->formatDisplay($rows); @@ -944,8 +938,8 @@ currency varchar(3) $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . - "country_id_op=in&country_id_value={$value}&" . - "$dateUrl", + "country_id_op=in&country_id_value={$value}&" . + "$dateUrl", $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); @@ -961,8 +955,8 @@ currency varchar(3) $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', "reset=1&force=1&" . - "state_province_id_op=in&state_province_id_value={$value}&" . - "$dateUrl", + "state_province_id_op=in&state_province_id_value={$value}&" . + "$dateUrl", $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index a71e115112..b3bff9a4f9 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -63,90 +63,80 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'display_name_creditor' => - array('title' => ts('Soft Credit Name'), + 'fields' => array( + 'display_name_creditor' => array( + 'title' => ts('Soft Credit Name'), 'name' => 'sort_name', 'alias' => 'contact_civireport', 'required' => TRUE, 'no_repeat' => TRUE, ), - 'id_creditor' => - array('title' => ts('Soft Credit Id'), + 'id_creditor' => array( + 'title' => ts('Soft Credit Id'), 'name' => 'id', 'alias' => 'contact_civireport', 'no_display' => TRUE, 'required' => TRUE, ), - 'display_name_constituent' => - array('title' => ts('Contributor Name'), + 'display_name_constituent' => array( + 'title' => ts('Contributor Name'), 'name' => 'sort_name', 'alias' => 'constituentname', 'required' => TRUE, ), - 'id_constituent' => - array('title' => ts('Const Id'), + 'id_constituent' => array( + 'title' => ts('Const Id'), 'name' => 'id', 'alias' => 'constituentname', 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), ), - 'filters' => - array( - 'sort_name' => - array( + 'filters' => array( + 'sort_name' => array( 'name' => 'sort_name', 'title' => ts('Soft Credit Name') ), ), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email_creditor' => - array('title' => ts('Soft Credit Email'), + 'fields' => array( + 'email_creditor' => array( + 'title' => ts('Soft Credit Email'), 'name' => 'email', 'alias' => 'emailcredit', 'default' => TRUE, 'no_repeat' => TRUE, ), - 'email_constituent' => - array('title' => ts('Contributor\'s Email'), + 'email_constituent' => array( + 'title' => ts('Contributor\'s Email'), 'name' => 'email', 'alias' => 'emailconst', ), ), 'grouping' => 'contact-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone_creditor' => - array('title' => ts('Soft Credit Phone'), + 'fields' => array( + 'phone_creditor' => array( + 'title' => ts('Soft Credit Phone'), 'name' => 'phone', 'alias' => 'pcredit', 'default' => TRUE, ), - 'phone_constituent' => - array('title' => ts('Contributor\'s Phone'), + 'phone_constituent' => array( + 'title' => ts('Contributor\'s Phone'), 'name' => 'phone', 'alias' => 'pconst', 'no_repeat' => TRUE, @@ -154,13 +144,11 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { ), 'grouping' => 'contact-fields', ), - 'civicrm_financial_type' => - array('dao' => 'CRM_Financial_DAO_FinancialType', - 'fields' => array('financial_type' => null,), - 'filters' => - array( - 'id' => - array( + 'civicrm_financial_type' => array( + 'dao' => 'CRM_Financial_DAO_FinancialType', + 'fields' => array('financial_type' => NULL,), + 'filters' => array( + 'id' => array( 'name' => 'id', 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -169,70 +157,62 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { ), 'grouping' => 'softcredit-fields', ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( + 'fields' => array( 'contribution_source' => NULL, 'currency' => array( 'required' => TRUE, 'no_display' => TRUE, ), - 'total_amount' => - array('title' => ts('Amount Statistics'), + 'total_amount' => array( + 'title' => ts('Amount Statistics'), 'default' => TRUE, - 'statistics' => - array('sum' => ts('Aggregate Amount'), + 'statistics' => array( + 'sum' => ts('Aggregate Amount'), 'count' => ts('Contributions'), 'avg' => ts('Average'), ), ), ), 'grouping' => 'softcredit-fields', - 'filters' => - array( - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'currency' => - array('title' => 'Currency', + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'currency' => array( + 'title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1), ), - 'total_amount' => - array('title' => ts('Contribution Amount'), + 'total_amount' => array( + 'title' => ts('Contribution Amount'), ), ), ), - 'civicrm_contribution_soft' => - array( + 'civicrm_contribution_soft' => array( 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => - array( - 'contribution_id' => - array('title' => ts('Contribution ID'), + 'fields' => array( + 'contribution_id' => array( + 'title' => ts('Contribution ID'), 'no_display' => TRUE, 'default' => TRUE, ), - 'id' => - array( + 'id' => array( 'default' => TRUE, 'no_display' => TRUE, ), 'soft_credit_type_id' => array('title' => ts('Soft Credit Type')), ), - 'filters' => - array( - 'soft_credit_type_id' => - array('title' => 'Soft Credit Type', + 'filters' => array( + 'soft_credit_type_id' => array( + 'title' => 'Soft Credit Type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, @@ -249,7 +229,8 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { 'title' => ts('Campaign'), 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -272,7 +253,9 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // include email column if set if ($tableName == 'civicrm_email') { @@ -346,8 +329,8 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { function from() { $alias_constituent = 'constituentname'; - $alias_creditor = 'contact_civireport'; - $this->_from = " + $alias_creditor = 'contact_civireport'; + $this->_from = " FROM civicrm_contribution {$this->_aliases['civicrm_contribution']} INNER JOIN civicrm_contribution_soft {$this->_aliases['civicrm_contribution_soft']} ON {$this->_aliases['civicrm_contribution_soft']}.contribution_id = @@ -405,8 +388,8 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { } function groupBy() { - $this->_rollup = 'WITH ROLLUP'; - $this->_groupBy = " + $this->_rollup = 'WITH ROLLUP'; + $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_contribution_soft']}.contact_id, constituentname.id {$this->_rollup}"; } @@ -438,8 +421,10 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $count = 0; $totalAmount = $average = array(); while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency).'('.$dao->count.')'; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $totalAmount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . '(' . + $dao->count . ')'; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } $statistics['counts']['amount'] = array( @@ -466,8 +451,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $this->buildACLClause(array('constituentname', 'contact_civireport')); $sql = $this->buildQuery(); - $dao = CRM_Core_DAO::executeQuery($sql); - $rows = $graphRows = array(); + $dao = CRM_Core_DAO::executeQuery($sql); + $rows = $graphRows = array(); $count = 0; while ($dao->fetch()) { $row = array(); @@ -493,9 +478,9 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency function alterDisplay(&$rows) { // custom code to alter rows - $entryFound = FALSE; + $entryFound = FALSE; $dispname_flag = $phone_flag = $email_flag = 0; - $prev_email = $prev_dispname = $prev_phone = NULL; + $prev_email = $prev_dispname = $prev_phone = NULL; foreach ($rows as $rowNum => $row) { // Link constituent (contributor) to contribution detail @@ -504,7 +489,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency ) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', - 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id_constituent'], + 'reset=1&force=1&id_op=eq&id_value=' . + $row['civicrm_contact_id_constituent'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_contact_display_name_constituent_link'] = $url; @@ -513,7 +499,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency } // convert soft credit contact name to link - if (array_key_exists('civicrm_contact_display_name_creditor', $row) && !empty($rows[$rowNum]['civicrm_contact_display_name_creditor']) && + if (array_key_exists('civicrm_contact_display_name_creditor', $row) && + !empty($rows[$rowNum]['civicrm_contact_display_name_creditor']) && array_key_exists('civicrm_contact_id_creditor', $row) ) { $url = CRM_Utils_System::url("civicrm/contact/view", diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 78a3108fae..fb539bdb5e 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -53,8 +53,8 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { */ function __construct() { - // Check if CiviCampaign is a) enabled and b) has active campaigns - $config = CRM_Core_Config::singleton(); + // Check if CiviCampaign is a) enabled and b) has active campaigns + $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); @@ -63,208 +63,186 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), - 'no_repeat' => TRUE, - ), - 'postal_greeting_display' => - array('title' => ts('Postal Greeting')), - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'no_repeat' => TRUE, + ), + 'postal_greeting_display' => array('title' => ts('Postal Greeting')), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), + 'grouping' => 'contact-fields', + 'group_bys' => array( + 'id' => array('title' => ts('Contact ID')), + 'sort_name' => array( + 'title' => ts('Contact Name'), + ), ), ), - 'grouping' => 'contact-fields', - 'group_bys' => - array( - 'id' => - array('title' => ts('Contact ID')), - 'sort_name' => - array('title' => ts('Contact Name'), + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'no_repeat' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), - 'no_repeat' => TRUE, + 'civicrm_financial_type' => array( + 'dao' => 'CRM_Financial_DAO_FinancialType', + 'fields' => array('financial_type' => NULL,), + 'grouping' => 'contri-fields', + 'group_bys' => array( + 'financial_type' => array('title' => ts('Financial Type')), ), ), - 'grouping' => 'contact-fields', - ), - 'civicrm_financial_type' => - array('dao' => 'CRM_Financial_DAO_FinancialType', - 'fields' => array('financial_type' => null,), - 'grouping' => 'contri-fields', - 'group_bys' => array( - 'financial_type' => array('title' => ts('Financial Type')), - ), - ), - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - //'bao' => 'CRM_Contribute_BAO_Contribution', - 'fields' => - array( - 'contribution_source' => array('title' => ts('Source'), ), - 'currency' => - array('required' => TRUE, - 'no_display' => TRUE, - ), - 'total_amount' => - array('title' => ts('Contribution Amount Stats'), - 'default' => TRUE, - 'statistics' => - array('sum' => ts('Contribution Aggregate'), - 'count' => ts('Contributions'), - 'avg' => ts('Contribution Avg'), + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + //'bao' => 'CRM_Contribute_BAO_Contribution', + 'fields' => array( + 'contribution_source' => array('title' => ts('Source'),), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, + ), + 'total_amount' => array( + 'title' => ts('Contribution Amount Stats'), + 'default' => TRUE, + 'statistics' => array( + 'sum' => ts('Contribution Aggregate'), + 'count' => ts('Contributions'), + 'avg' => ts('Contribution Avg'), + ), ), ), - ), - 'grouping' => 'contri-fields', - 'filters' => - array( - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - 'type' => CRM_Utils_Type::T_INT, - ), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'financial_type_id' => - array('title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'contribution_page_id' => - array('title' => ts('Contribution Page'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionPage(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'total_amount' => - array('title' => ts('Contribution Amount'), - ), - 'total_sum' => - array('title' => ts('Contribution Aggregate'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_sum', - 'having' => TRUE, - ), - 'total_count' => - array('title' => ts('Contribution Count'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_count', - 'having' => TRUE, - ), - 'total_avg' => - array('title' => ts('Contribution Avg'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_avg', - 'having' => TRUE, - ), - ), - 'group_bys' => - array( - 'receive_date' => - array( - 'frequency' => TRUE, - 'default' => TRUE, - 'chart' => TRUE, + 'grouping' => 'contri-fields', + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + 'type' => CRM_Utils_Type::T_INT, + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'contribution_page_id' => array( + 'title' => ts('Contribution Page'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionPage(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'total_amount' => array( + 'title' => ts('Contribution Amount'), + ), + 'total_sum' => array( + 'title' => ts('Contribution Aggregate'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_sum', + 'having' => TRUE, + ), + 'total_count' => array( + 'title' => ts('Contribution Count'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_count', + 'having' => TRUE, + ), + 'total_avg' => array( + 'title' => ts('Contribution Avg'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_avg', + 'having' => TRUE, + ), ), - 'contribution_source' => NULL, - ), - ), - 'civicrm_contribution_soft' => - array( - 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => - array( - 'soft_amount' => - array( - 'title' => ts('Soft Credit Amount Stats'), - 'name' => 'amount', - 'statistics' => - array('sum' => ts('Soft Credit Aggregate'), - 'count' => ts('Soft Credits'), - 'avg' => ts('Soft Credit Avg'), + 'group_bys' => array( + 'receive_date' => array( + 'frequency' => TRUE, + 'default' => TRUE, + 'chart' => TRUE, ), + 'contribution_source' => NULL, ), ), - 'grouping' => 'contri-fields', - 'filters' => - array( - 'amount' => - array('title' => ts('Soft Credit Amount'), - ), - 'soft_credit_type_id' => - array('title' => 'Soft Credit Type', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'soft_sum' => - array('title' => ts('Soft Credit Aggregate'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum', - 'having' => TRUE, - ), - 'soft_count' => - array('title' => ts('Soft Credits Count'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count', - 'having' => TRUE, + 'civicrm_contribution_soft' => array( + 'dao' => 'CRM_Contribute_DAO_ContributionSoft', + 'fields' => array( + 'soft_amount' => array( + 'title' => ts('Soft Credit Amount Stats'), + 'name' => 'amount', + 'statistics' => array( + 'sum' => ts('Soft Credit Aggregate'), + 'count' => ts('Soft Credits'), + 'avg' => ts('Soft Credit Avg'), + ), + ), ), - 'soft_avg' => - array('title' => ts('Soft Credit Avg'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg', - 'having' => TRUE, + 'grouping' => 'contri-fields', + 'filters' => array( + 'amount' => array( + 'title' => ts('Soft Credit Amount'), + ), + 'soft_credit_type_id' => array( + 'title' => 'Soft Credit Type', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'soft_sum' => array( + 'title' => ts('Soft Credit Aggregate'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum', + 'having' => TRUE, + ), + 'soft_count' => array( + 'title' => ts('Soft Credits Count'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count', + 'having' => TRUE, + ), + 'soft_avg' => array( + 'title' => ts('Soft Credit Avg'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg', + 'having' => TRUE, + ), ), ), - ), - ) + $this->addAddressFields(); + ) + $this->addAddressFields(); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { @@ -272,7 +250,8 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'title' => 'Campaign', 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -310,36 +289,37 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { if (!empty($this->_params['group_bys'][$fieldName])) { switch (CRM_Utils_Array::value($fieldName, $this->_params['group_bys_freq'])) { case 'YEARWEEK': - $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; + $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Week'; break; case 'YEAR': - $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Year'; break; case 'MONTH': - $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; - $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; + $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Month'; break; case 'QUARTER': - $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Quarter'; break; } if (!empty($this->_params['group_bys_freq'][$fieldName])) { $this->_interval = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning'; + $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = + $field['title'] . ' Beginning'; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type']; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName]; @@ -358,7 +338,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // only include statistics columns if set if (!empty($field['statistics'])) { @@ -424,7 +406,10 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } if (empty($fields['fields']['total_amount'])) { foreach (array( - 'total_count_value', 'total_sum_value', 'total_avg_value') as $val) { + 'total_count_value', + 'total_sum_value', + 'total_avg_value' + ) as $val) { if (!empty($fields[$val])) { $errors[$val] = ts("Please select the Amount Statistics"); } @@ -436,7 +421,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { function from() { $softCreditJoin = "LEFT"; - if (!empty($this->_params['fields']['soft_amount']) && empty($this->_params['fields']['total_amount'])) { + if (!empty($this->_params['fields']['soft_amount']) && + empty($this->_params['fields']['total_amount']) + ) { // if its only soft credit stats, use inner join $softCreditJoin = "INNER"; } @@ -481,12 +468,14 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $this->assign('chartSupported', TRUE); } - if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params['group_bys_freq'][$fieldName])) { + if (!empty($table['group_bys'][$fieldName]['frequency']) && + !empty($this->_params['group_bys_freq'][$fieldName]) + ) { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') - )) { + array('year') + )) { $append = ''; } $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})"; @@ -501,22 +490,26 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } if (!empty($this->_statFields) && - (($append && count($this->_groupBy) <= 1) || (!$append)) && !$this->_having + (($append && count($this->_groupBy) <= 1) || (!$append)) && + !$this->_having ) { $this->_rollup = " WITH ROLLUP"; } - $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . " {$this->_rollup} "; + $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . + " {$this->_rollup} "; } else { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id"; } } - function storeWhereHavingClauseArray(){ + function storeWhereHavingClauseArray() { parent::storeWhereHavingClauseArray(); - if (empty($this->_params['fields']['soft_amount']) && !empty($this->_havingClauses)){ + if (empty($this->_params['fields']['soft_amount']) && + !empty($this->_havingClauses) + ) { foreach ($this->_havingClauses as $key => $havingClause) { - if (stristr($havingClause, 'soft_soft')){ + if (stristr($havingClause, 'soft_soft')) { unset($this->_havingClauses[$key]); } } @@ -532,7 +525,8 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $statistics = parent::statistics($rows); $softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']); - $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']); + $onlySoftCredit = $softCredit && + !CRM_Utils_Array::value('total_amount', $this->_params['fields']); $totalAmount = $average = $softTotalAmount = $softAverage = array(); $select = "SELECT @@ -554,12 +548,16 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $totalAmount = $average = $softTotalAmount = $softAverage = array(); $count = $softCount = 0; while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_total_amount_count.")"; + $totalAmount[] = + CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency) . + " (" . $dao->civicrm_contribution_total_amount_count . ")"; $average[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_avg, $dao->currency); $count += $dao->civicrm_contribution_total_amount_count; if ($softCredit) { - $softTotalAmount[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency)." (".$dao->civicrm_contribution_soft_soft_amount_count.")"; + $softTotalAmount[] = + CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency) . + " (" . $dao->civicrm_contribution_soft_soft_amount_count . ")"; $softAverage[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_avg, $dao->currency); $softCount += $dao->civicrm_contribution_soft_soft_amount_count; } @@ -625,10 +623,12 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ // both contri & soft contri stats are present $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum']; $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum']; - } else if ($softContrib) { + } + else if ($softContrib) { // only soft contributions $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum']; - } else { + } + else { // only contributions $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum']; } @@ -639,12 +639,13 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $graphRows['barKeys'][0] = ts('Contributions'); $graphRows['barKeys'][1] = ts('Soft Credits'); $graphRows['legend'] = ts('Contributions and Soft Credits'); - } else if ($softContrib) { + } + else if ($softContrib) { $graphRows['legend'] = ts('Soft Credits'); } // build the chart. - $config = CRM_Core_Config::Singleton(); + $config = CRM_Core_Config::Singleton(); $graphRows['xname'] = $this->_interval; $graphRows['yname'] = "Amount ({$config->defaultCurrency})"; CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval); @@ -662,46 +663,49 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ foreach ($rows as $rowNum => $row) { // make count columns point to detail report - if (!empty($this->_params['group_bys']['receive_date']) && !empty($row['civicrm_contribution_receive_date_start']) && - CRM_Utils_Array::value('civicrm_contribution_receive_date_start', $row) && !empty($row['civicrm_contribution_receive_date_subtotal'])) { + if (!empty($this->_params['group_bys']['receive_date']) && + !empty($row['civicrm_contribution_receive_date_start']) && + CRM_Utils_Array::value('civicrm_contribution_receive_date_start', $row) && + !empty($row['civicrm_contribution_receive_date_subtotal']) + ) { $dateStart = CRM_Utils_Date::customFormat($row['civicrm_contribution_receive_date_start'], '%Y%m%d'); - $endDate = new DateTime($dateStart); - $dateEnd = array(); + $endDate = new DateTime($dateStart); + $dateEnd = array(); list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d')); switch (strtolower($this->_params['group_bys_freq']['receive_date'])) { case 'month': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 1, - $dateEnd['d'] - 1, $dateEnd['Y'] - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + )); break; case 'year': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], - $dateEnd['d'] - 1, $dateEnd['Y'] + 1 - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + 1 + )); break; case 'yearweek': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], - $dateEnd['d'] + 6, $dateEnd['Y'] - )); + $dateEnd['d'] + 6, $dateEnd['Y'] + )); break; case 'quarter': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 3, - $dateEnd['d'] - 1, $dateEnd['Y'] - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + )); break; } $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', - "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}", - $this->_absoluteUrl, - $this->_id, - $this->_drilldownReport - ); + "reset=1&force=1&receive_date_from={$dateStart}&receive_date_to={$dateEnd}", + $this->_absoluteUrl, + $this->_id, + $this->_drilldownReport + ); $rows[$rowNum]['civicrm_contribution_receive_date_start_link'] = $url; $rows[$rowNum]['civicrm_contribution_receive_date_start_hover'] = ts('List all contribution(s) for this date unit.'); $entryFound = TRUE; diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index ddc4ffcbec..e1831a4677 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -45,10 +45,10 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { * */ function __construct() { - $yearsInPast = 10; + $yearsInPast = 10; $yearsInFuture = 1; - $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); - $count = $date['maxYear']; + $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); + $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; @@ -64,114 +64,101 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'grouping' => 'contact-field', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'required' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'grouping' => 'contact-field', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'required' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), ), - 'first_name' => array( - 'title' => ts('First Name'), - ), - 'last_name' => array( - 'title' => ts('Last Name'), - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'operator' => 'like', + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'operator' => 'like', + ), ), ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'grouping' => 'contact-field', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'default' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'grouping' => 'contact-field', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'default' => TRUE, + ), ), ), - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'grouping' => 'contact-field', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), - 'default' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'grouping' => 'contact-field', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'default' => TRUE, + ), ), ), - ), - ) - + $this->addAddressFields() - + array( - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contact_id' => - array('title' => ts('contactId'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, + ) + + $this->addAddressFields() + + array( + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'contact_id' => array( + 'title' => ts('contactId'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'total_amount' => array( + 'title' => ts('Total Amount'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'receive_date' => array( + 'title' => ts('Year'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), ), - 'total_amount' => - array('title' => ts('Total Amount'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'receive_date' => - array('title' => ts('Year'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, + 'filters' => array( + 'yid' => array( + 'name' => 'receive_date', + 'title' => ts('This Year'), + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => $optionYear, + 'default' => date('Y'), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array('1'), + ), ), ), - 'filters' => - array( - 'yid' => - array( - 'name' => 'receive_date', - 'title' => ts('This Year'), - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => $optionYear, - 'default' => date('Y'), - ), - 'financial_type_id' => - array('title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array('1'), - ), - ), - ), - ); + ); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { @@ -179,7 +166,8 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { 'title' => ts('Campaign'), 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -207,7 +195,9 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($fieldName == 'total_amount') { $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}"; @@ -227,7 +217,8 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $this->_columnHeaders["civicrm_life_time_total"]['title'] = 'LifeTime';; } elseif ($fieldName == 'receive_date') { - $select[] = self::fiscalYearOffset($field['dbAlias']) . " as {$tableName}_{$fieldName}"; + $select[] = self::fiscalYearOffset($field['dbAlias']) . + " as {$tableName}_{$fieldName}"; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; @@ -278,12 +269,16 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { if ($fieldName == 'yid') { $clause = "contribution_civireport.contact_id NOT IN (SELECT distinct cont.id FROM civicrm_contact cont, civicrm_contribution contri - WHERE cont.id = contri.contact_id AND " . self::fiscalYearOffset('contri.receive_date') . " = {$this->_params['yid_value']} AND contri.is_test = 0 )"; + WHERE cont.id = contri.contact_id AND " . + self::fiscalYearOffset('contri.receive_date') . + " = {$this->_params['yid_value']} AND contri.is_test = 0 )"; } - elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { + elseif (CRM_Utils_Array::value('type', $field) & + CRM_Utils_Type::T_DATE + ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -298,7 +293,9 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params) ); - if (($fieldName == 'contribution_status_id' || $fieldName == 'financial_type_id') && !empty($clause)) { + if (($fieldName == 'contribution_status_id' || + $fieldName == 'financial_type_id') && !empty($clause) + ) { $this->_statusClause .= " AND " . $clause; } } @@ -320,7 +317,10 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { function groupBy() { $this->assign('chartSupported', TRUE); - $this->_groupBy = "Group BY {$this->_aliases['civicrm_contribution']}.contact_id, " . self::fiscalYearOffset($this->_aliases['civicrm_contribution'] . '.receive_date') . " WITH ROLLUP "; + $this->_groupBy = + "Group BY {$this->_aliases['civicrm_contribution']}.contact_id, " . + self::fiscalYearOffset($this->_aliases['civicrm_contribution'] . + '.receive_date') . " WITH ROLLUP "; } /** @@ -378,19 +378,22 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; } else { - $sql = "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . implode(',', $contactIds) . ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; + $sql = + "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . + implode(',', $contactIds) . + ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; } - $current_year = $this->_params['yid_value']; - $previous_year = $current_year - 1; - $previous_pyear = $current_year - 2; + $current_year = $this->_params['yid_value']; + $previous_year = $current_year - 1; + $previous_pyear = $current_year - 2; $previous_ppyear = $current_year - 3; - $upTo_year = $current_year - 4; + $upTo_year = $current_year - 4; - $rows = $row = array(); - $dao = CRM_Core_DAO::executeQuery($sql); + $rows = $row = array(); + $dao = CRM_Core_DAO::executeQuery($sql); $contributionSum = 0; - $yearcal = array(); + $yearcal = array(); while ($dao->fetch()) { if (!$dao->civicrm_contribution_contact_id) { continue; @@ -409,8 +412,10 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { } else { $rows[$dao->civicrm_contribution_contact_id]['civicrm_life_time_total'] = $dao->civicrm_contribution_total_amount; - if (($dao->civicrm_contribution_total_amount - $contributionSum) > 0) { - $rows[$dao->civicrm_contribution_contact_id]["civicrm_upto_{$upTo_year}"] = $dao->civicrm_contribution_total_amount - $contributionSum; + if (($dao->civicrm_contribution_total_amount - $contributionSum) > 0 + ) { + $rows[$dao->civicrm_contribution_contact_id]["civicrm_upto_{$upTo_year}"] = + $dao->civicrm_contribution_total_amount - $contributionSum; } $contributionSum = 0; } @@ -431,13 +436,13 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { * @param $rows */ function buildChart(&$rows) { - $graphRows = array(); - $count = 0; - $current_year = $this->_params['yid_value']; - $previous_year = $current_year - 1; - $previous_two_year = $current_year - 2; + $graphRows = array(); + $count = 0; + $current_year = $this->_params['yid_value']; + $previous_year = $current_year - 1; + $previous_two_year = $current_year - 2; $previous_three_year = $current_year - 3; - $upto = $current_year - 4; + $upto = $current_year - 4; $interval[$previous_year] = $previous_year; $interval[$previous_two_year] = $previous_two_year; @@ -445,15 +450,23 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $interval["upto_{$upto}"] = "Up To {$upto}"; foreach ($rows as $key => $row) { - $display["upto_{$upto}"] = CRM_Utils_Array::value("upto_{$upto}", $display) + CRM_Utils_Array::value("civicrm_upto_{$upto}", $row); - $display[$previous_year] = CRM_Utils_Array::value($previous_year, $display) + CRM_Utils_Array::value($previous_year, $row); - $display[$previous_two_year] = CRM_Utils_Array::value($previous_two_year, $display) + CRM_Utils_Array::value($previous_two_year, $row); - $display[$previous_three_year] = CRM_Utils_Array::value($previous_three_year, $display) + CRM_Utils_Array::value($previous_three_year, $row); + $display["upto_{$upto}"] = + CRM_Utils_Array::value("upto_{$upto}", $display) + + CRM_Utils_Array::value("civicrm_upto_{$upto}", $row); + $display[$previous_year] = + CRM_Utils_Array::value($previous_year, $display) + + CRM_Utils_Array::value($previous_year, $row); + $display[$previous_two_year] = + CRM_Utils_Array::value($previous_two_year, $display) + + CRM_Utils_Array::value($previous_two_year, $row); + $display[$previous_three_year] = + CRM_Utils_Array::value($previous_three_year, $display) + + CRM_Utils_Array::value($previous_three_year, $row); } $graphRows['value'] = $display; - $config = CRM_Core_Config::Singleton(); - $chartInfo = array( + $config = CRM_Core_Config::Singleton(); + $chartInfo = array( 'legend' => 'Sybunt Report', 'xname' => 'Year', 'yname' => "Amount ({$config->defaultCurrency})", @@ -478,7 +491,8 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { array_key_exists('civicrm_contribution_contact_id', $row) ) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', - 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contribution_contact_id'], + 'reset=1&force=1&id_op=eq&id_value=' . + $row['civicrm_contribution_contact_id'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; @@ -513,7 +527,10 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { */ function getOperationPair($type = "string", $fieldName = NULL) { if ($fieldName == 'yid') { - return array('calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting')); + return array( + 'calendar' => ts('Is Calendar Year'), + 'fiscal' => ts('Fiscal Year Starting') + ); } return parent::getOperationPair($type, $fieldName); } diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index c8c72e4e19..d7f82f28c1 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -53,120 +53,106 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'display_name' => - array('title' => ts('Contact Name'), - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'first_name' => array( - 'title' => ts('First Name'), - ), - 'last_name' => array( - 'title' => ts('Last Name'), - ), - 'contact_type' => - array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - ), - ), - ), - ) - + $this->getAddressColumns() - + array( - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'total_amount' => - array('title' => ts('Amount Statistics'), - 'required' => TRUE, - 'statistics' => - array('sum' => ts('Aggregate Amount'), - 'count' => ts('Donations'), - 'avg' => ts('Average'), + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'display_name' => array( + 'title' => ts('Contact Name'), + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), ), - ), - 'currency' => - array('required' => TRUE, - 'no_display' => TRUE, ), ), - 'filters' => - array( - 'receive_date' => - array( - 'default' => 'this.year', - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, + ) + + $this->getAddressColumns() + + array( + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'total_amount' => array( + 'title' => ts('Amount Statistics'), + 'required' => TRUE, + 'statistics' => array( + 'sum' => ts('Aggregate Amount'), + 'count' => ts('Donations'), + 'avg' => ts('Average'), + ), + ), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, ), - 'total_range' => - array('title' => ts('Show no. of Top Donors'), - 'type' => CRM_Utils_Type::T_INT, - 'default_op' => 'eq', - ), - 'financial_type_id' => - array('name' => 'financial_type_id', - 'title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType() , ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), + 'filters' => array( + 'receive_date' => array( + 'default' => 'this.year', + 'operatorType' => CRM_Report_Form::OP_DATE, + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'total_range' => array( + 'title' => ts('Show no. of Top Donors'), + 'type' => CRM_Utils_Type::T_INT, + 'default_op' => 'eq', + ), + 'financial_type_id' => array( + 'name' => 'financial_type_id', + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + ), ), ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), - 'default' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'default' => TRUE, + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'email-fields', ), - 'grouping' => 'email-fields', - ), - - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), - 'default' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'default' => TRUE, + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'phone-fields', ), - 'grouping' => 'phone-fields', - ), - ); + ); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -189,7 +175,9 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // only include statistics columns if set if (!empty($field['statistics'])) { foreach ($field['statistics'] as $stat => $label) { @@ -245,7 +233,10 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { $val = CRM_Utils_Array::value('total_range_value', $fields); if (!in_array($op, array( - 'eq', 'lte'))) { + 'eq', + 'lte' + )) + ) { $errors['total_range_op'] = ts("Please select 'Is equal to' OR 'Is Less than or equal to' operator"); } @@ -279,8 +270,8 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -416,7 +407,7 @@ ORDER BY civicrm_contribution_total_amount_sum DESC unset($_POST['crmPID_B']); } else { - $pageId = max((int)@$_POST['crmPID_B'], 1); + $pageId = max((int) @$_POST['crmPID_B'], 1); } } @@ -445,9 +436,12 @@ ORDER BY civicrm_contribution_total_amount_sum DESC $rows[$rowNum]['civicrm_donor_rank'] = $rank++; // convert display name to links if (array_key_exists('civicrm_contact_display_name', $row) && - array_key_exists('civicrm_contact_id', $row) && !empty($row['civicrm_contribution_currency'])) { + array_key_exists('civicrm_contact_id', $row) && + !empty($row['civicrm_contribution_currency']) + ) { $url = CRM_Report_Utils_Report::getNextUrl('contribute/detail', - 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'] . "¤cy_value=" . $row['civicrm_contribution_currency'], + 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'] . + "¤cy_value=" . $row['civicrm_contribution_currency'], $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_contact_display_name_link'] = $url; diff --git a/CRM/Report/Form/Event/IncomeCountSummary.php b/CRM/Report/Form/Event/IncomeCountSummary.php index 4876c915ea..e498bb46ed 100644 --- a/CRM/Report/Form/Event/IncomeCountSummary.php +++ b/CRM/Report/Form/Event/IncomeCountSummary.php @@ -117,20 +117,18 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event { 'participant_count' => array( 'title' => ts('Participants'), 'default' => TRUE, - 'statistics' => - array( - 'count' => ts('Participants'), - ), + 'statistics' => array( + 'count' => ts('Participants'), + ), ), 'line_total' => array( 'title' => ts('Income Statistics'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, - 'statistics' => - array( - 'sum' => ts('Income'), - 'avg' => ts('Average'), - ), + 'statistics' => array( + 'sum' => ts('Income'), + 'avg' => ts('Average'), + ), ), ), ), @@ -168,7 +166,9 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if (!empty($field['statistics'])) { foreach ($field['statistics'] as $stat => $label) { switch (strtolower($stat)) { @@ -322,18 +322,26 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event { while ($dao->fetch()) { $row = array(); foreach ($this->_columnHeaders as $key => $value) { - if (($key == 'civicrm_event_start_date') || ($key == 'civicrm_event_end_date')) { + if (($key == 'civicrm_event_start_date') || + ($key == 'civicrm_event_end_date') + ) { //get event start date and end date in custom datetime format $row[$key] = CRM_Utils_Date::customFormat($dao->$key); } elseif ($key == 'civicrm_participant_fee_amount_avg') { - if ($dao->civicrm_participant_fee_amount_sum && $dao->civicrm_line_item_participant_count_count) { - $row[$key] = $dao->civicrm_participant_fee_amount_sum / $dao->civicrm_line_item_participant_count_count; + if ($dao->civicrm_participant_fee_amount_sum && + $dao->civicrm_line_item_participant_count_count + ) { + $row[$key] = $dao->civicrm_participant_fee_amount_sum / + $dao->civicrm_line_item_participant_count_count; } } elseif ($key == 'civicrm_line_item_line_total_avg') { - if ($dao->civicrm_line_item_line_total_sum && $dao->civicrm_line_item_participant_count_count) { - $row[$key] = $dao->civicrm_line_item_line_total_sum / $dao->civicrm_line_item_participant_count_count; + if ($dao->civicrm_line_item_line_total_sum && + $dao->civicrm_line_item_participant_count_count + ) { + $row[$key] = $dao->civicrm_line_item_line_total_sum / + $dao->civicrm_line_item_participant_count_count; } } else { @@ -366,7 +374,8 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event { if ($value['civicrm_event_id']) { $graphRows['totalParticipants'][] = ($rows[$key]['civicrm_line_item_participant_count_count']); $graphRows[$this->_interval][] = - substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . $rows[$key]['civicrm_event_id'] . ") "; + substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . + $rows[$key]['civicrm_event_id'] . ") "; $graphRows['value'][] = ($rows[$key]['civicrm_line_item_participant_count_count']); } } diff --git a/CRM/Report/Form/Event/ParticipantListCount.php b/CRM/Report/Form/Event/ParticipantListCount.php index 37c0bc737e..4aec9ee494 100644 --- a/CRM/Report/Form/Event/ParticipantListCount.php +++ b/CRM/Report/Form/Event/ParticipantListCount.php @@ -53,215 +53,196 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Name'), 'default' => TRUE, 'no_repeat' => TRUE, 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), 'grouping' => 'contact-fields', 'filters' => array( - 'sort_name' => - array('title' => ts('Participant Name'), + 'sort_name' => array( + 'title' => ts('Participant Name'), 'operator' => 'like', ), ), ), - 'civicrm_employer' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'grouping' => 'contact-fields', - 'fields' => array( - 'id' => array( - 'no_display' => true, - 'required' => true, + 'civicrm_employer' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'grouping' => 'contact-fields', + 'fields' => array( + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, ), 'organization_name' => array( - 'title' => 'Employer', - 'default' => TRUE, - 'no_repeat' => TRUE, + 'title' => 'Employer', + 'default' => TRUE, + 'no_repeat' => TRUE, ), ), ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', 'fields' => array( - 'email' => - array('title' => ts('Email'), + 'email' => array( + 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', - 'filters' => - array( - 'email' => - array('title' => ts('Participant E-mail'), + 'filters' => array( + 'email' => array( + 'title' => ts('Participant E-mail'), 'operator' => 'like', ), ), ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'grouping' => 'contact-fields', - 'fields' => array( - 'phone' => array( - 'title' => ts( 'Phone No' ), - 'default' => true, - ), - ), - ), - 'civicrm_address' => - array( + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'grouping' => 'contact-fields', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone No'), + 'default' => TRUE, + ), + ), + ), + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), ), ), 'grouping' => 'contact-fields', ), - 'civicrm_participant' => - array( + 'civicrm_participant' => array( 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => - array( - 'participant_id' => - array('title' => ts('Participant ID'), + 'fields' => array( + 'participant_id' => array( + 'title' => ts('Participant ID'), 'default' => TRUE, ), - 'event_id' => - array('title' => ts('Event'), + 'event_id' => array( + 'title' => ts('Event'), 'type' => CRM_Utils_Type::T_STRING, ), - 'role_id' => - array('title' => ts('Role'), + 'role_id' => array( + 'title' => ts('Role'), 'default' => TRUE, ), - 'status_id' => - array('title' => ts('Status'), + 'status_id' => array( + 'title' => ts('Status'), 'default' => TRUE, ), - 'participant_register_date' => - array('title' => ts('Registration Date'), + 'participant_register_date' => array( + 'title' => ts('Registration Date'), ), ), 'grouping' => 'event-fields', - 'filters' => - array( + 'filters' => array( 'event_id' => array( 'name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0)), + 'attributes' => array( + 'entity' => 'event', + 'select' => array('minimumInputLength' => 0) + ), ), - 'sid' => - array( + 'sid' => array( 'name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), ), - 'rid' => - array( + 'rid' => array( 'name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT_SEPARATOR, 'options' => CRM_Event_PseudoConstant::participantRole(), ), - 'participant_register_date' => array('title' => ts('Registration Date'), + 'participant_register_date' => array( + 'title' => ts('Registration Date'), 'operatorType' => CRM_Report_Form::OP_DATE, ), ), - 'group_bys' => - array( - 'event_id' => - array('title' => ts('Event'), + 'group_bys' => array( + 'event_id' => array( + 'title' => ts('Event'), ), ), ), - 'civicrm_event' => - array( + 'civicrm_event' => array( 'dao' => 'CRM_Event_DAO_Event', - 'fields' => - array( - 'event_type_id' => - array('title' => ts('Event Type'), + 'fields' => array( + 'event_type_id' => array( + 'title' => ts('Event Type'), ), - 'start_date' => - array('title' => ts('Event Start Date'), + 'start_date' => array( + 'title' => ts('Event Start Date'), ), - 'end_date' => - array('title' => ts('Event End Date'), + 'end_date' => array( + 'title' => ts('Event End Date'), ), ), 'grouping' => 'event-fields', 'filters' => array( - 'eid' => - array( + 'eid' => array( 'name' => 'event_type_id', 'title' => ts('Event Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), ), - 'event_start_date' => - array( + 'event_start_date' => array( 'name' => 'start_date', 'title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'event_end_date' => - array( + 'event_end_date' => array( 'name' => 'end_date', 'title' => ts('Event End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, ), ), - 'group_bys' => - array( - 'event_type_id' => - array('title' => ts('Event Type '), + 'group_bys' => array( + 'event_type_id' => array( + 'title' => ts('Event Type '), ), ), ), - 'civicrm_line_item' => - array( + 'civicrm_line_item' => array( 'dao' => 'CRM_Price_DAO_LineItem', - 'fields' => - array( - 'line_total' => - array('title' => ts('Income'), + 'fields' => array( + 'line_total' => array( + 'title' => ts('Income'), 'default' => TRUE, - 'statistics' => - array('sum' => ts('Amount'), + 'statistics' => array( + 'sum' => ts('Amount'), 'avg' => ts('Average'), ), ), - 'participant_count' => - array('title' => ts('Count'), + 'participant_count' => array( + 'title' => ts('Count'), 'default' => TRUE, - 'statistics' => - array('sum' => ts('Count'), + 'statistics' => array( + 'sum' => ts('Count'), ), ), ), @@ -269,12 +250,12 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { ); $this->_options = array( - 'blank_column_begin' => - array('title' => ts('Blank column at the Begining'), + 'blank_column_begin' => array( + 'title' => ts('Blank column at the Begining'), 'type' => 'checkbox', ), - 'blank_column_end' => - array('title' => ts('Blank column at the End'), + 'blank_column_end' => array( + 'title' => ts('Blank column at the End'), 'type' => 'select', 'options' => array( '' => '-select-', @@ -300,8 +281,8 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { function statistics(&$rows) { $statistics = parent::statistics($rows); - $avg = NULL; - $select = " SELECT SUM( {$this->_aliases['civicrm_line_item']}.participant_count ) as count, + $avg = NULL; + $select = " SELECT SUM( {$this->_aliases['civicrm_line_item']}.participant_count ) as count, SUM( {$this->_aliases['civicrm_line_item']}.line_total ) as amount "; $sql = "{$select} {$this->_from} {$this->_where}"; @@ -336,14 +317,18 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { $this->_columnHeaders = array(); //add blank column at the Start - if (array_key_exists('options', $this->_params) && !empty($this->_params['options']['blank_column_begin'])) { + if (array_key_exists('options', $this->_params) && + !empty($this->_params['options']['blank_column_begin']) + ) { $select[] = " '' as blankColumnBegin"; $this->_columnHeaders['blankColumnBegin']['title'] = '_ _ _ _'; } foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if (!empty($field['statistics'])) { foreach ($field['statistics'] as $stat => $label) { switch (strtolower($stat)) { @@ -433,12 +418,14 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { } if (!empty($this->_groupBy)) { - $this->_groupBy = "ORDER BY " . implode(', ', $this->_groupBy) . ", {$this->_aliases['civicrm_contact']}.sort_name"; + $this->_groupBy = "ORDER BY " . implode(', ', $this->_groupBy) . + ", {$this->_aliases['civicrm_contact']}.sort_name"; } else { $this->_groupBy = "ORDER BY {$this->_aliases['civicrm_contact']}.sort_name"; } - $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_participant']}.id " . $this->_groupBy; + $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_participant']}.id " . + $this->_groupBy; } function postProcess() { @@ -496,7 +483,9 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event { ) { if ($value = $row['civicrm_participant_participant_id']) { $url = CRM_Utils_System::url("civicrm/contact/view/participant", - 'reset=1&id=' . $row['civicrm_participant_participant_id'] . '&cid=' . $row['civicrm_contact_id'] . '&action=view&context=participant', + 'reset=1&id=' . $row['civicrm_participant_participant_id'] . + '&cid=' . $row['civicrm_contact_id'] . + '&action=view&context=participant', $this->_absoluteUrl ); $rows[$rowNum]['civicrm_participant_participant_id_link'] = $url; diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index 79bcc9178d..d87d370ca6 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -43,7 +43,12 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { protected $_tagFilter = TRUE; protected $activeCampaigns; - protected $_customGroupExtends = array('Participant', 'Contact', 'Individual', 'Event'); + protected $_customGroupExtends = array( + 'Participant', + 'Contact', + 'Individual', + 'Event' + ); public $_drilldownReport = array('event/income' => 'Link to Detail Report'); @@ -66,128 +71,116 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { } $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name_linked' => - array('title' => ts('Participant Name'), + 'fields' => array( + 'sort_name_linked' => array( + 'title' => ts('Participant Name'), 'required' => TRUE, 'no_repeat' => TRUE, 'dbAlias' => 'contact_civireport.sort_name', ), - 'first_name' => array('title' => ts('First Name'), + 'first_name' => array( + 'title' => ts('First Name'), ), - 'last_name' => array('title' => ts('Last Name'), + 'last_name' => array( + 'title' => ts('Last Name'), ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'gender_id' => - array('title' => ts('Gender'), + 'gender_id' => array( + 'title' => ts('Gender'), ), - 'birth_date' => - array('title' => ts('Birth Date'), + 'birth_date' => array( + 'title' => ts('Birth Date'), ), 'age' => array( - 'title' => ts('Age'), + 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', ), 'age_at_event' => array( - 'title' => ts('Age at Event'), + 'title' => ts('Age at Event'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, event_civireport.start_date)', ), - 'employer_id' => - array('title' => ts('Organization'), + 'employer_id' => array( + 'title' => ts('Organization'), ), ), 'grouping' => 'contact-fields', - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Last Name, First Name'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', ), - 'gender_id' => - array( + 'gender_id' => array( 'name' => 'gender_id', 'title' => ts('Gender'), ), - 'birth_date' => - array( + 'birth_date' => array( 'name' => 'birth_date', 'title' => ts('Birth Date'), ), - 'age_at_event' => - array( + 'age_at_event' => array( 'name' => 'age_at_event', 'title' => ts('Age at Event'), ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Participant Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Participant Name'), 'operator' => 'like', ), - 'gender_id' => - array('title' => ts('Gender'), + 'gender_id' => array( + 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), ), 'birth_date' => array( 'title' => 'Birth Date', 'operatorType' => CRM_Report_Form::OP_DATE, - 'type' => CRM_Utils_Type::T_DATE + 'type' => CRM_Utils_Type::T_DATE ), ), ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Email'), + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', - 'filters' => - array( - 'email' => - array('title' => ts('Participant E-mail'), + 'filters' => array( + 'email' => array( + 'title' => ts('Participant E-mail'), 'operator' => 'like', ), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), ), ), 'grouping' => 'contact-fields', ), - 'civicrm_participant' => - array( + 'civicrm_participant' => array( 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => - array('participant_id' => array('title' => 'Participant ID'), + 'fields' => array( + 'participant_id' => array('title' => 'Participant ID'), 'participant_record' => array( 'name' => 'id', 'no_display' => TRUE, @@ -197,11 +190,13 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, ), - 'status_id' => array('title' => ts('Status'), - 'default' => TRUE, + 'status_id' => array( + 'title' => ts('Status'), + 'default' => TRUE, ), - 'role_id' => array('title' => ts('Role'), - 'default' => TRUE, + 'role_id' => array( + 'title' => ts('Role'), + 'default' => TRUE, ), 'fee_currency' => array( 'required' => TRUE, @@ -212,14 +207,16 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'participant_register_date' => array('title' => ts('Registration Date')), ), 'grouping' => 'event-fields', - 'filters' => - array( + 'filters' => array( 'event_id' => array( 'name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0)), + 'attributes' => array( + 'entity' => 'event', + 'select' => array('minimumInputLength' => 0) + ), ), 'sid' => array( 'name' => 'status_id', @@ -237,8 +234,8 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'title' => 'Registration Date', 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'fee_currency' => - array('title' => ts('Fee Currency'), + 'fee_currency' => array( + 'title' => ts('Fee Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, @@ -246,40 +243,38 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { ), ), - 'order_bys' => - array( - 'participant_register_date' => - array('title' => ts('Registration Date'), + 'order_bys' => array( + 'participant_register_date' => array( + 'title' => ts('Registration Date'), 'default_weight' => '1', 'default_order' => 'ASC', ), - 'event_id' => - array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC'), + 'event_id' => array( + 'title' => ts('Event'), + 'default_weight' => '1', + 'default_order' => 'ASC' + ), ), ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Phone'), + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_event' => - array( + 'civicrm_event' => array( 'dao' => 'CRM_Event_DAO_Event', 'fields' => array( 'event_type_id' => array('title' => ts('Event Type')), 'event_start_date' => array('title' => ts('Event Start Date')), ), 'grouping' => 'event-fields', - 'filters' => - array( + 'filters' => array( 'eid' => array( 'name' => 'event_type_id', 'title' => ts('Event Type'), @@ -291,10 +286,12 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'operatorType' => CRM_Report_Form::OP_DATE, ), ), - 'order_bys' => - array( - 'event_type_id' => - array('title' => ts('Event Type'), 'default_weight' => '2', 'default_order' => 'ASC'), + 'order_bys' => array( + 'event_type_id' => array( + 'title' => ts('Event Type'), + 'default_weight' => '2', + 'default_order' => 'ASC' + ), ), ), 'civicrm_contribution' => array( @@ -329,28 +326,31 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event { 'title' => 'Payment Date', 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'financial_type_id' => array('title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), ), - 'currency' => array('title' => ts('Contribution Currency'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, + 'currency' => array( + 'title' => ts('Contribution Currency'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, ), - 'payment_instrument_id' => array('title' => ts('Payment Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), - 'contribution_status_id' => array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => NULL + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => NULL ), ), ), - 'civicrm_line_item' => array( 'dao' => 'CRM_Price_DAO_LineItem', 'grouping' => 'priceset-fields', @@ -436,17 +436,21 @@ GROUP BY cv.label $this->_columnHeaders = array(); //add blank column at the Start - if (array_key_exists('options', $this->_params) && !empty($this->_params['options']['blank_column_begin'])) { + if (array_key_exists('options', $this->_params) && + !empty($this->_params['options']['blank_column_begin']) + ) { $select[] = " '' as blankColumnBegin"; $this->_columnHeaders['blankColumnBegin']['title'] = '_ _ _ _'; } foreach ($this->_columns as $tableName => $table) { - if ($tableName == 'civicrm_line_item'){ + if ($tableName == 'civicrm_line_item') { $this->_lineitemField = TRUE; } if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_contribution') { $this->_contribField = TRUE; } @@ -512,7 +516,7 @@ GROUP BY cv.label ON (pp.contribution_id = {$this->_aliases['civicrm_contribution']}.id) "; } - if ($this->_lineitemField){ + if ($this->_lineitemField) { $this->_from .= " LEFT JOIN civicrm_line_item line_item_civireport ON line_item_civireport.entity_table = 'civicrm_participant' AND @@ -530,8 +534,8 @@ GROUP BY cv.label if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -543,17 +547,18 @@ GROUP BY cv.label if ($fieldName == 'rid') { $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); if (!empty($value)) { - $clause = "( {$field['dbAlias']} REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', $value) . "[[:>:]]' )"; + $clause = "( {$field['dbAlias']} REGEXP '[[:<:]]" . + implode('[[:>:]]|[[:<:]]', $value) . "[[:>:]]' )"; } $op = NULL; } if ($op) { $clause = $this->whereClause($field, - $op, - CRM_Utils_Array::value("{$fieldName}_value", $this->_params), - CRM_Utils_Array::value("{$fieldName}_min", $this->_params), - CRM_Utils_Array::value("{$fieldName}_max", $this->_params) + $op, + CRM_Utils_Array::value("{$fieldName}_value", $this->_params), + CRM_Utils_Array::value("{$fieldName}_min", $this->_params), + CRM_Utils_Array::value("{$fieldName}_max", $this->_params) ); } } @@ -568,14 +573,16 @@ GROUP BY cv.label $this->_where = "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 "; } else { - $this->_where = "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 AND " . implode(' AND ', $clauses); + $this->_where = + "WHERE {$this->_aliases['civicrm_participant']}.is_test = 0 AND " . + implode(' AND ', $clauses); } if ($this->_aclWhere) { $this->_where .= " AND {$this->_aclWhere} "; } } - function groupBy(){ + function groupBy() { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_participant']}.id"; } @@ -613,7 +620,7 @@ GROUP BY cv.label * @param $rowNum * @param $types */ - private function _initBasicRow(&$rows, &$entryFound, $row, $rowId, $rowNum, $types){ + private function _initBasicRow(&$rows, &$entryFound, $row, $rowId, $rowNum, $types) { if (!array_key_exists($rowId, $row)) { return FALSE; } @@ -634,7 +641,7 @@ GROUP BY cv.label $entryFound = FALSE; $eventType = CRM_Core_OptionGroup::values('event_type'); - $financialTypes = CRM_Contribute_PseudoConstant::financialType(); + $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id', array('localize' => TRUE)); @@ -648,8 +655,8 @@ GROUP BY cv.label $rows[$rowNum]['civicrm_participant_event_id'] = CRM_Event_PseudoConstant::event($eventId, FALSE); $url = CRM_Report_Utils_Report::getNextUrl('event/income', - 'reset=1&force=1&id_op=in&id_value=' . $eventId, - $this->_absoluteUrl, $this->_id, $this->_drilldownReport + 'reset=1&force=1&id_op=in&id_value=' . $eventId, + $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $rows[$rowNum]['civicrm_participant_event_id_link'] = $url; $rows[$rowNum]['civicrm_participant_event_id_hover'] = ts("View Event Income Details for this Event"); @@ -700,12 +707,12 @@ GROUP BY cv.label if ($displayName && $cid && $id) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', - "reset=1&force=1&id_op=eq&id_value=$cid", - $this->_absoluteUrl, $this->_id, $this->_drilldownReport + "reset=1&force=1&id_op=eq&id_value=$cid", + $this->_absoluteUrl, $this->_id, $this->_drilldownReport ); $viewUrl = CRM_Utils_System::url("civicrm/contact/view/participant", - "reset=1&id=$id&cid=$cid&action=view&context=participant" + "reset=1&id=$id&cid=$cid&action=view&context=participant" ); $contactTitle = ts('View Contact Details'); @@ -713,7 +720,9 @@ GROUP BY cv.label $rows[$rowNum]['civicrm_contact_sort_name_linked'] = "$displayName"; if ($this->_outputMode !== 'csv') { - $rows[$rowNum]['civicrm_contact_sort_name_linked'] .= "" . ts('View') . ""; + $rows[$rowNum]['civicrm_contact_sort_name_linked'] .= + "" . + ts('View') . ""; } $entryFound = TRUE; } @@ -725,7 +734,7 @@ GROUP BY cv.label $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($countryId, TRUE); } $entryFound = TRUE; - } + } // Handle state/province id if (array_key_exists('civicrm_address_state_province_id', $row)) { @@ -738,11 +747,11 @@ GROUP BY cv.label // Handle employer id if (array_key_exists('civicrm_contact_employer_id', $row)) { - $employerId = $row['civicrm_contact_employer_id']; + $employerId = $row['civicrm_contact_employer_id']; if ($employerId) { $rows[$rowNum]['civicrm_contact_employer_id'] = CRM_Contact_BAO_Contact::displayName($employerId); $url = CRM_Utils_System::url('civicrm/contact/view', - 'reset=1&cid=' . $employerId, $this->_absoluteUrl + 'reset=1&cid=' . $employerId, $this->_absoluteUrl ); $rows[$rowNum]['civicrm_contact_employer_id_link'] = $url; $rows[$rowNum]['civicrm_contact_employer_id_hover'] = ts('View Contact Summary for this Contact.'); diff --git a/CRM/Report/Form/Event/Summary.php b/CRM/Report/Form/Event/Summary.php index 2c94619bfb..f66022181e 100644 --- a/CRM/Report/Form/Event/Summary.php +++ b/CRM/Report/Form/Event/Summary.php @@ -46,7 +46,8 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { protected $_add2groupSupported = FALSE; protected $_customGroupExtends = array( - 'Event'); + 'Event' + ); public $_drilldownReport = array('event/income' => 'Link to Detail Report'); /** @@ -58,31 +59,32 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { function __construct() { $this->_columns = array( - 'civicrm_event' => - array( + 'civicrm_event' => array( 'dao' => 'CRM_Event_DAO_Event', - 'fields' => - array( + 'fields' => array( 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'title' => array('title' => ts('Event Title'), + 'title' => array( + 'title' => ts('Event Title'), 'required' => TRUE, ), - 'event_type_id' => array('title' => ts('Event Type'), + 'event_type_id' => array( + 'title' => ts('Event Type'), 'required' => TRUE, ), 'fee_label' => array('title' => ts('Fee Label')), - 'event_start_date' => array('title' => ts('Event Start Date'), + 'event_start_date' => array( + 'title' => ts('Event Start Date'), ), 'event_end_date' => array('title' => ts('Event End Date')), - 'max_participants' => array('title' => ts('Capacity'), + 'max_participants' => array( + 'title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT, ), ), - 'filters' => - array( + 'filters' => array( 'id' => array( 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, @@ -119,7 +121,9 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } } @@ -142,8 +146,8 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -234,7 +238,7 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { $participant_info[$event_id]['totalAmount'] = $amt; $participant_info[$event_id]['statusType1'] = $particiType1; $participant_info[$event_id]['statusType2'] = $particiType2; - $participant_info[$event_id]['currency'] = $currency[$event_id]; + $participant_info[$event_id]['currency'] = $currency[$event_id]; $amt = $particiType1 = $particiType2 = 0; } @@ -248,7 +252,9 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); @@ -298,7 +304,9 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { while ($dao->fetch()) { $row = array(); foreach ($this->_columnHeaders as $key => $value) { - if (($key == 'civicrm_event_start_date') || ($key == 'civicrm_event_end_date')) { + if (($key == 'civicrm_event_start_date') || + ($key == 'civicrm_event_end_date') + ) { //get event start date and end date in custom datetime format $row[$key] = CRM_Utils_Date::customFormat($dao->$key); } @@ -338,7 +346,9 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { if (!empty($this->_params['charts'])) { foreach ($rows as $key => $value) { $graphRows['totalAmount'][] = $graphRows['value'][] = CRM_Utils_Array::value('totalAmount', $rows[$key]); - $graphRows[$this->_interval][] = substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . $rows[$key]['civicrm_event_id'] . ") "; + $graphRows[$this->_interval][] = + substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . + $rows[$key]['civicrm_event_id'] . ") "; } if (CRM_Utils_Array::value('totalAmount', $rows[$key]) == 0) { @@ -376,7 +386,9 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event { $eventType = CRM_Core_OptionGroup::values('event_type'); foreach ($rows as $rowNum => $row) { - if (array_key_exists('totalAmount', $row) && array_key_exists('currency', $row)) { + if (array_key_exists('totalAmount', $row) && + array_key_exists('currency', $row) + ) { $rows[$rowNum]['totalAmount'] = CRM_Utils_Money::format($rows[$rowNum]['totalAmount'], $rows[$rowNum]['currency']); } if (array_key_exists('civicrm_event_title', $row)) { diff --git a/CRM/Report/Form/Extended.php b/CRM/Report/Form/Extended.php index 8954f2f318..3ec494baf7 100644 --- a/CRM/Report/Form/Extended.php +++ b/CRM/Report/Form/Extended.php @@ -145,8 +145,11 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { foreach ($this->_columns as $tablename => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $field => $specs) { - if (in_array($tablename . '_' . $field, $selectedFields) && array_key_exists('alter_display', $specs)) { - $alterfunctions[$tablename . '_' . $field] = $specs['alter_display']; + if (in_array($tablename . '_' . $field, $selectedFields) && + array_key_exists('alter_display', $specs) + ) { + $alterfunctions[$tablename . '_' . + $field] = $specs['alter_display']; $altermap[$tablename . '_' . $field] = $field; } } @@ -171,54 +174,47 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { */ function getLineItemColumns() { return array( - 'civicrm_line_item' => - array( + 'civicrm_line_item' => array( 'dao' => 'CRM_Price_BAO_LineItem', - 'fields' => - array( - 'qty' => - array('title' => ts('Quantity'), + 'fields' => array( + 'qty' => array( + 'title' => ts('Quantity'), 'type' => CRM_Utils_Type::T_INT, - 'statistics' => - array('sum' => ts('Total Quantity Selected')), + 'statistics' => array('sum' => ts('Total Quantity Selected')), ), - 'unit_price' => - array('title' => ts('Unit Price'), + 'unit_price' => array( + 'title' => ts('Unit Price'), ), - 'line_total' => - array('title' => ts('Line Total'), + 'line_total' => array( + 'title' => ts('Line Total'), 'type' => CRM_Utils_Type::T_MONEY, - 'statistics' => - array('sum' => ts('Total of Line Items')), + 'statistics' => array('sum' => ts('Total of Line Items')), ), ), - 'participant_count' => - array('title' => ts('Participant Count'), - 'statistics' => - array('sum' => ts('Total Participants')), + 'participant_count' => array( + 'title' => ts('Participant Count'), + 'statistics' => array('sum' => ts('Total Participants')), ), - 'filters' => - array( - 'qty' => - array('title' => ts('Quantity'), + 'filters' => array( + 'qty' => array( + 'title' => ts('Quantity'), 'type' => CRM_Utils_Type::T_INT, 'operator' => CRM_Report_Form::OP_INT, ), ), - 'group_bys' => - array( - 'price_field_id' => - array('title' => ts('Price Field'), + 'group_bys' => array( + 'price_field_id' => array( + 'title' => ts('Price Field'), ), - 'price_field_value_id' => - array('title' => ts('Price Field Option'), + 'price_field_value_id' => array( + 'title' => ts('Price Field Option'), ), - 'line_item_id' => - array('title' => ts('Individual Line Item'), + 'line_item_id' => array( + 'title' => ts('Individual Line Item'), 'name' => 'id', + ), ), ), - ), ); } @@ -227,41 +223,37 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { */ function getPriceFieldValueColumns() { return array( - 'civicrm_price_field_value' => - array( + 'civicrm_price_field_value' => array( 'dao' => 'CRM_Price_BAO_PriceFieldValue', 'fields' => array( - 'price_field_value_label' => - array('title' => ts('Price Field Value Label'), + 'price_field_value_label' => array( + 'title' => ts('Price Field Value Label'), 'name' => 'label', ), ), - 'filters' => - array( - 'price_field_value_label' => - array('title' => ts('Price Fields Value Label'), + 'filters' => array( + 'price_field_value_label' => array( + 'title' => ts('Price Fields Value Label'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', 'name' => 'label', ), ), - 'order_bys' => - array( - 'label' => - array('title' => ts('Price Field Value Label'), + 'order_bys' => array( + 'label' => array( + 'title' => ts('Price Field Value Label'), ), ), - 'group_bys' => - //note that we have a requirement to group by label such that all 'Promo book' lines + 'group_bys' => //note that we have a requirement to group by label such that all 'Promo book' lines // are grouped together across price sets but there may be a separate need to group // by id so that entries in one price set are distinct from others. Not quite sure what // to call the distinction for end users benefit - array( - 'price_field_value_label' => - array('title' => ts('Price Field Value Label'), - 'name' => 'label', + array( + 'price_field_value_label' => array( + 'title' => ts('Price Field Value Label'), + 'name' => 'label', + ), ), - ), ), ); } @@ -271,36 +263,31 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { */ function getPriceFieldColumns() { return array( - 'civicrm_price_field' => - array( + 'civicrm_price_field' => array( 'dao' => 'CRM_Price_BAO_PriceField', - 'fields' => - array( - 'price_field_label' => - array('title' => ts('Price Field Label'), + 'fields' => array( + 'price_field_label' => array( + 'title' => ts('Price Field Label'), 'name' => 'label', ), ), - 'filters' => - array( - 'price_field_label' => - array('title' => ts('Price Field Label'), + 'filters' => array( + 'price_field_label' => array( + 'title' => ts('Price Field Label'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', 'name' => 'label', ), ), - 'order_bys' => - array( - 'price_field_label' => - array('title' => ts('Price Field Label'), - 'name' => 'label', + 'order_bys' => array( + 'price_field_label' => array( + 'title' => ts('Price Field Label'), + 'name' => 'label', ), ), - 'group_bys' => - array( - 'price_field_label' => - array('title' => ts('Price Field Label'), + 'group_bys' => array( + 'price_field_label' => array( + 'title' => ts('Price Field Label'), 'name' => 'label', ), ), @@ -317,23 +304,25 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC'); } return array( - 'civicrm_participant' => - array( + 'civicrm_participant' => array( 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => - array('participant_id' => array('title' => 'Participant ID'), + 'fields' => array( + 'participant_id' => array('title' => 'Participant ID'), 'participant_record' => array( 'name' => 'id', 'title' => ts('Participant ID'), ), - 'event_id' => array('title' => ts('Event ID'), + 'event_id' => array( + 'title' => ts('Event ID'), 'type' => CRM_Utils_Type::T_STRING, 'alter_display' => 'alterEventID', ), - 'status_id' => array('title' => ts('Status'), + 'status_id' => array( + 'title' => ts('Status'), 'alter_display' => 'alterParticipantStatus', ), - 'role_id' => array('title' => ts('Role'), + 'role_id' => array( + 'title' => ts('Role'), 'alter_display' => 'alterParticipantRole', ), 'participant_fee_level' => NULL, @@ -341,9 +330,9 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'participant_register_date' => array('title' => ts('Registration Date')), ), 'grouping' => 'event-fields', - 'filters' => - array( - 'event_id' => array('name' => 'event_id', + 'filters' => array( + 'event_id' => array( + 'name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $_events['all'], @@ -365,15 +354,15 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'operatorType' => CRM_Report_Form::OP_DATE, ), ), - 'order_bys' => - array( - 'event_id' => - array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC'), + 'order_bys' => array( + 'event_id' => array( + 'title' => ts('Event'), + 'default_weight' => '1', + 'default_order' => 'ASC' + ), ), - 'group_bys' => - array( - 'event_id' => - array('title' => ts('Event')), + 'group_bys' => array( + 'event_id' => array('title' => ts('Event')), ), ), ); @@ -449,24 +438,27 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { return array( 'civicrm_event' => array( 'dao' => 'CRM_Event_DAO_Event', - 'fields' => - array( + 'fields' => array( 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'title' => array('title' => ts('Event Title'), + 'title' => array( + 'title' => ts('Event Title'), 'required' => TRUE, ), - 'event_type_id' => array('title' => ts('Event Type'), + 'event_type_id' => array( + 'title' => ts('Event Type'), 'required' => TRUE, 'alter_display' => 'alterEventType', ), 'fee_label' => array('title' => ts('Fee Label')), - 'event_start_date' => array('title' => ts('Event Start Date'), - ), + 'event_start_date' => array( + 'title' => ts('Event Start Date'), + ), 'event_end_date' => array('title' => ts('Event End Date')), - 'max_participants' => array('title' => ts('Capacity'), + 'max_participants' => array( + 'title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT, ), ), @@ -493,8 +485,8 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { ), 'group_bys' => array( 'event_type_id' => array( - 'title' => ts('Event Type'), - ), + 'title' => ts('Event Type'), + ), ), ), ); @@ -505,19 +497,19 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { */ function getContributionColumns() { return array( - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( + 'fields' => array( 'contribution_id' => array( 'name' => 'id', ), - 'financial_type_id' => array('title' => ts('Financial Type'), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), 'default' => TRUE, 'alter_display' => 'alterContributionType', ), - 'payment_instrument_id' => array('title' => ts('Payment Instrument'), + 'payment_instrument_id' => array( + 'title' => ts('Payment Instrument'), 'alter_display' => 'alterPaymentType', ), 'source' => array('title' => 'Contribution Source'), @@ -526,52 +518,46 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, - 'total_amount' => array('title' => ts('Amount'), - 'statistics' => - array('sum' => ts('Total Amount')), + 'total_amount' => array( + 'title' => ts('Amount'), + 'statistics' => array('sum' => ts('Total Amount')), 'type' => CRM_Utils_Type::T_MONEY, ), ), - 'filters' => - array( - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'financial_type_id' => - array('title' => ts('Financial Type'), + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), ), - 'payment_instrument_id' => - array('title' => ts('Payment Type'), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), ), - 'total_amount' => - array('title' => ts('Contribution Amount')), + 'total_amount' => array('title' => ts('Contribution Amount')), ), - 'order_bys' => - array( - 'payment_instrument_id' => - array('title' => ts('Payment Instrument'), + 'order_bys' => array( + 'payment_instrument_id' => array( + 'title' => ts('Payment Instrument'), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), ), - 'financial_type_id' => - array('title' => ts('Financial Type'), - ), ), - 'group_bys' => - array('financial_type_id' => - array('title' => ts('Financial Type')), - 'payment_instrument_id' => - array('title' => ts('Payment Instrument')), - 'contribution_id' => - array('title' => ts('Individual Contribution'), + 'group_bys' => array( + 'financial_type_id' => array('title' => ts('Financial Type')), + 'payment_instrument_id' => array('title' => ts('Payment Instrument')), + 'contribution_id' => array( + 'title' => ts('Individual Contribution'), 'name' => 'id', - ), + ), 'source' => array('title' => 'Contribution Source'), ), 'grouping' => 'contribution-fields', @@ -609,7 +595,7 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'id' => array( 'title' => ts('Contact ID'), ) - , + , 'sort_name' => array( 'title' => ts('Contact Name'), ), @@ -637,39 +623,39 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'fields' => array( 'id' => array( 'title' => ts('Case ID'), - 'required' => false + 'required' => FALSE ), 'subject' => array( 'title' => ts('Case Subject'), - 'default' => true + 'default' => TRUE ), 'status_id' => array( 'title' => ts('Status'), - 'default' => true + 'default' => TRUE ), 'case_type_id' => array( 'title' => ts('Case Type'), - 'default' => true + 'default' => TRUE ), 'case_start_date' => array( 'title' => ts('Case Start Date'), 'name' => 'start_date', - 'default' => true + 'default' => TRUE ), 'case_end_date' => array( 'title' => ts('Case End Date'), 'name' => 'end_date', - 'default' => true + 'default' => TRUE ), 'case_duration' => array( 'name' => 'duration', 'title' => ts('Duration (Days)'), - 'default' => false + 'default' => FALSE ), 'case_is_deleted' => array( 'name' => 'is_deleted', 'title' => ts('Case Deleted?'), - 'default' => false, + 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT ) ), @@ -723,9 +709,11 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { */ /** * Get address columns to add to array + * * @param array $options * - prefix Prefix to add to table (in case of more than one instance of the table) * - prefix_label Label to give columns from this address table instance + * * @return array address columns definition */ /** @@ -737,15 +725,15 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { $defaultOptions = array( 'prefix' => '', 'prefix_label' => '', - 'group_by' => false, - 'order_by' => true, - 'filters' => true, + 'group_by' => FALSE, + 'order_by' => TRUE, + 'filters' => TRUE, 'defaults' => array( 'country_id' => TRUE ), - ); + ); - $options = array_merge($defaultOptions,$options); + $options = array_merge($defaultOptions, $options); $addressFields = array( $options['prefix'] . 'civicrm_address' => array( @@ -764,12 +752,14 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'name' => 'street_address', ), $options['prefix'] . 'supplemental_address_1' => array( - 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 1'), + 'title' => ts($options['prefix_label'] . + 'Supplementary Address Field 1'), 'default' => CRM_Utils_Array::value('supplemental_address_1', $options['defaults'], FALSE), 'name' => 'supplemental_address_1', ), $options['prefix'] . 'supplemental_address_2' => array( - 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 2'), + 'title' => ts($options['prefix_label'] . + 'Supplementary Address Field 2'), 'default' => CRM_Utils_Array::value('supplemental_address_2', $options['defaults'], FALSE), 'name' => 'supplemental_address_2', ), @@ -814,7 +804,7 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { 'title' => ts($options['prefix_label'] . 'State/Province'), 'default' => CRM_Utils_Array::value('state_province_id', $options['defaults'], FALSE), 'alter_display' => 'alterStateProvinceID', - 'name' => 'state_province_id', + 'name' => 'state_province_id', ), $options['prefix'] . 'country_id' => array( 'title' => ts($options['prefix_label'] . 'Country'), @@ -828,7 +818,7 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { ); if ($options['filters']) { - $addressFields[$options['prefix'] .'civicrm_address']['filters'] = array( + $addressFields[$options['prefix'] . 'civicrm_address']['filters'] = array( $options['prefix'] . 'street_number' => array( 'title' => ts($options['prefix_label'] . 'Street Number'), 'type' => 1, @@ -874,7 +864,8 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { } if ($options['order_by']) { - $addressFields[$options['prefix'] . 'civicrm_address']['order_bys'] = array( + $addressFields[$options['prefix'] . + 'civicrm_address']['order_bys'] = array( $options['prefix'] . 'street_name' => array( 'title' => ts($options['prefix_label'] . 'Street Name'), 'name' => 'street_name', @@ -1027,9 +1018,12 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { /** * @param string $prefix */ - function joinAddressFromContact( $prefix = '') { - $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases[$prefix . 'civicrm_address']} - ON {$this->_aliases[$prefix . 'civicrm_address']}.contact_id = {$this->_aliases[$prefix . 'civicrm_contact']}.id"; + function joinAddressFromContact($prefix = '') { + $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases[$prefix . + 'civicrm_address']} + ON {$this->_aliases[$prefix . + 'civicrm_address']}.contact_id = {$this->_aliases[$prefix . + 'civicrm_contact']}.id"; } function joinPriceFieldValueFromLineItem() { @@ -1241,7 +1235,7 @@ WHERE line_item_civireport.id IS NOT NULL * @return string */ function alterNickName($value, &$row) { - if(empty($row['civicrm_contact_id'])){ + if (empty($row['civicrm_contact_id'])) { return; } $contactID = $row['civicrm_contact_id']; @@ -1330,9 +1324,10 @@ WHERE line_item_civireport.id IS NOT NULL function alterCountryID($value, &$row, $selectedfield, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; - $row[$selectedfield . '_hover'] = ts("%1 for this country.", array(1 => $value)); - $countries = CRM_Core_PseudoConstant::country($value, FALSE); - if(!is_array($countries)){ + $row[$selectedfield . + '_hover'] = ts("%1 for this country.", array(1 => $value)); + $countries = CRM_Core_PseudoConstant::country($value, FALSE); + if (!is_array($countries)) { return $countries; } } @@ -1345,12 +1340,13 @@ WHERE line_item_civireport.id IS NOT NULL * * @return array */ - function alterCountyID($value, &$row,$selectedfield, $criteriaFieldName) { + function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; - $row[$selectedfield . '_hover'] = ts("%1 for this county.", array(1 => $value)); + $row[$selectedfield . + '_hover'] = ts("%1 for this county.", array(1 => $value)); $counties = CRM_Core_PseudoConstant::county($value, FALSE); - if(!is_array($counties)){ + if (!is_array($counties)) { return $counties; } } @@ -1366,10 +1362,11 @@ WHERE line_item_civireport.id IS NOT NULL function alterStateProvinceID($value, &$row, $selectedfield, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; - $row[$selectedfield . '_hover'] = ts("%1 for this state.", array(1 => $value)); + $row[$selectedfield . + '_hover'] = ts("%1 for this state.", array(1 => $value)); - $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE); - if(!is_array($states)){ + $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE); + if (!is_array($states)) { return $states; } } @@ -1382,7 +1379,8 @@ WHERE line_item_civireport.id IS NOT NULL * @return mixed */ function alterContactID($value, &$row, $fieldname) { - $row[$fieldname . '_link'] = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $value, $this->_absoluteUrl); + $row[$fieldname . '_link'] = CRM_Utils_System::url("civicrm/contact/view", + 'reset=1&cid=' . $value, $this->_absoluteUrl); return $value; } diff --git a/CRM/Report/Form/Grant/Detail.php b/CRM/Report/Form/Grant/Detail.php index 13e626f2b6..3fa60230ee 100644 --- a/CRM/Report/Form/Grant/Detail.php +++ b/CRM/Report/Form/Grant/Detail.php @@ -38,7 +38,8 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { protected $_addressField = FALSE; protected $_customGroupExtends = array( - 'Grant'); + 'Grant' + ); /** * @@ -48,195 +49,160 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), 'grouping' => 'contact-fields', - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'operator' => 'like', ), - 'gender_id' => - array('title' => ts('Gender'), + 'gender_id' => array( + 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), ), - 'id' => - array('title' => ts('Contact ID'), + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, ), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'filters' => - array( - 'country_id' => - array('title' => ts('Country'), + 'filters' => array( + 'country_id' => array( + 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), ), ), ), - 'civicrm_grant' => - array( + 'civicrm_grant' => array( 'dao' => 'CRM_Grant_DAO_Grant', - 'fields' => - array( - 'grant_type_id' => - array( + 'fields' => array( + 'grant_type_id' => array( 'name' => 'grant_type_id', 'title' => ts('Grant Type'), ), - 'status_id' => - array( + 'status_id' => array( 'name' => 'status_id', 'title' => ts('Grant Status'), ), - 'amount_total' => - array( + 'amount_total' => array( 'name' => 'amount_total', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY, ), - 'amount_granted' => - array( + 'amount_granted' => array( 'name' => 'amount_granted', 'title' => ts('Amount Granted'), ), - 'application_received_date' => - array( + 'application_received_date' => array( 'name' => 'application_received_date', 'title' => ts('Application Received'), 'default' => TRUE, ), - 'money_transfer_date' => - array( + 'money_transfer_date' => array( 'name' => 'money_transfer_date', 'title' => ts('Money Transfer Date'), 'type' => CRM_Utils_Type::T_DATE, ), - 'grant_due_date' => - array( + 'grant_due_date' => array( 'name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'type' => CRM_Utils_Type::T_DATE, ), - 'decision_date' => - array( + 'decision_date' => array( 'name' => 'decision_date', 'title' => ts('Grant Decision Date'), 'type' => CRM_Utils_Type::T_DATE, ), - 'rationale' => - array( + 'rationale' => array( 'name' => 'rationale', 'title' => ts('Rationale'), ), - 'grant_report_received' => - array( + 'grant_report_received' => array( 'name' => 'grant_report_received', 'title' => ts('Grant Report Received'), ), ), - 'filters' => - array( - 'grant_type' => - array( + 'filters' => array( + 'grant_type' => array( 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), ), - 'status_id' => - array( + 'status_id' => array( 'name' => 'status_id', 'title' => ts('Grant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), ), - 'amount_granted' => - array( + 'amount_granted' => array( 'title' => ts('Amount Granted'), 'operatorType' => CRM_Report_Form::OP_INT, ), - 'amount_total' => - array( + 'amount_total' => array( 'title' => ts('Amount Requested'), 'operatorType' => CRM_Report_Form::OP_INT, ), - 'application_received_date' => - array( + 'application_received_date' => array( 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'money_transfer_date' => - array( + 'money_transfer_date' => array( 'title' => ts('Money Transfer Date'), 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'grant_due_date' => - array( + 'grant_due_date' => array( 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Report_Form::OP_DATE, ), - 'decision_date' => - array( + 'decision_date' => array( 'title' => ts('Grant Decision Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), ), - 'group_bys' => - array( - 'grant_type_id' => - array( + 'group_bys' => array( + 'grant_type_id' => array( 'title' => ts('Grant Type'), ), - 'status_id' => - array( + 'status_id' => array( 'title' => ts('Grant Status'), ), - 'amount_total' => - array( + 'amount_total' => array( 'title' => ts('Amount Requested'), ), - 'amount_granted' => - array( + 'amount_granted' => array( 'title' => ts('Amount Granted'), ), - 'application_received_date' => - array( + 'application_received_date' => array( 'title' => ts('Application Received Date'), ), - 'money_transfer_date' => - array( + 'money_transfer_date' => array( 'title' => ts('Money Transfer Date'), ), - 'decision_date' => - array( + 'decision_date' => array( 'title' => ts('Grant Decision Date'), ), ), @@ -256,7 +222,9 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { } if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; @@ -294,8 +262,8 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -338,7 +306,8 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { } } if (!empty($this->_groupBy)) { - $this->_groupBy = "ORDER BY " . implode(', ', $this->_groupBy) . ", {$this->_aliases['civicrm_contact']}.sort_name"; + $this->_groupBy = "ORDER BY " . implode(', ', $this->_groupBy) . + ", {$this->_aliases['civicrm_contact']}.sort_name"; } else { $this->_groupBy = "ORDER BY {$this->_aliases['civicrm_contact']}.sort_name"; diff --git a/CRM/Report/Form/Grant/Statistics.php b/CRM/Report/Form/Grant/Statistics.php index 0fae03ddfb..990d93aeaa 100644 --- a/CRM/Report/Form/Grant/Statistics.php +++ b/CRM/Report/Form/Grant/Statistics.php @@ -49,142 +49,117 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_grant' => - array( + 'civicrm_grant' => array( 'dao' => 'CRM_Grant_DAO_Grant', - 'fields' => - array( - 'summary_statistics' => - array( + 'fields' => array( + 'summary_statistics' => array( 'name' => 'id', 'title' => ts('Summary Statistics'), 'required' => TRUE, ), - 'grant_type_id' => - array( + 'grant_type_id' => array( 'name' => 'grant_type_id', 'title' => ts('By Grant Type'), ), - 'status_id' => - array( + 'status_id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'amount_total' => - array( + 'amount_total' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'grant_report_received' => - array( + 'grant_report_received' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'currency' => - array( + 'currency' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'filters' => - array( - 'application_received_date' => - array( + 'filters' => array( + 'application_received_date' => array( 'name' => 'application_received_date', 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'decision_date' => - array( + 'decision_date' => array( 'name' => 'decision_date', 'title' => ts('Grant Decision'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'money_transfer_date' => - array( + 'money_transfer_date' => array( 'name' => 'money_transfer_date', 'title' => ts('Money Transferred'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'grant_due_date' => - array( + 'grant_due_date' => array( 'name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, ), - 'grant_type' => - array( + 'grant_type' => array( 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), ), - 'status_id' => - array( + 'status_id' => array( 'name' => 'status_id', 'title' => ts('Grant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), ), - 'amount_requested' => - array( + 'amount_requested' => array( 'name' => 'amount_requested', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY, ), - 'amount_granted' => - array( + 'amount_granted' => array( 'name' => 'amount_granted', 'title' => ts('Amount Granted'), ), - 'grant_report_received' => - array( + 'grant_report_received' => array( 'name' => 'grant_report_received', 'title' => ts('Report Received'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('- select -'), + 'options' => array( + '' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'), ), ), ), ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'id' => - array( + 'fields' => array( + 'id' => array( 'required' => TRUE, 'no_display' => TRUE, ), - 'gender_id' => - array( + 'gender_id' => array( 'name' => 'gender_id', 'title' => ts('By Gender'), ), - 'contact_type' => - array( + 'contact_type' => array( 'name' => 'contact_type', 'title' => ts('By Contact Type'), ), ), - 'filters' => - array( - 'gender_id' => - array( + 'filters' => array( + 'gender_id' => array( 'name' => 'gender_id', 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), ), - 'contact_type' => - array( + 'contact_type' => array( 'name' => 'contact_type', 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -193,25 +168,19 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { ), 'grouping' => 'contact-fields', ), - 'civicrm_world_region' => - array( + 'civicrm_world_region' => array( 'dao' => 'CRM_Core_DAO_Worldregion', - 'fields' => - array( - 'id' => - array( + 'fields' => array( + 'id' => array( 'no_display' => TRUE, ), - 'name' => - array( + 'name' => array( 'name' => 'name', 'title' => ts('By World Region'), ), ), - 'filters' => - array( - 'region_id' => - array( + 'filters' => array( + 'region_id' => array( 'name' => 'id', 'title' => ts('World Region'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -219,21 +188,17 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { ), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( - 'country_id' => - array( + 'fields' => array( + 'country_id' => array( 'name' => 'country_id', 'title' => ts('By Country'), ), ), - 'filters' => - array( - 'country_id' => - array('title' => ts('Country'), + 'filters' => array( + 'country_id' => array( + 'title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), ), @@ -249,13 +214,17 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { $this->_columnHeaders = array(); foreach ($this->_columns as $tableName => $table) { if (in_array($tableName, array( - 'civicrm_address', 'civicrm_world_region'))) { + 'civicrm_address', + 'civicrm_world_region' + ))) { $this->_addressField = TRUE; } if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; @@ -302,8 +271,8 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -312,7 +281,8 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL else { $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); if (($fieldName == 'grant_report_received') && - (CRM_Utils_Array::value("{$fieldName}_value", $this->_params) === 0) + (CRM_Utils_Array::value("{$fieldName}_value", $this->_params) === + 0) ) { $op = 'nll'; $this->_params["{$fieldName}_value"] = NULL; @@ -329,7 +299,8 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL if (!empty($clause)) { $clauses[] = $clause; $this->_where .= " AND " . implode(' AND ', $clauses); - $this->_whereClause = $whereClause . " AND " . implode(' AND ', $clauses); + $this->_whereClause = $whereClause . " AND " . + implode(' AND ', $clauses); } } } @@ -383,14 +354,14 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL * @param $rows */ function alterDisplay(&$rows) { - $totalStatistics = $grantStatistics = array(); - $totalStatistics = parent::statistics($rows); + $totalStatistics = $grantStatistics = array(); + $totalStatistics = parent::statistics($rows); $awardedGrantsAmount = $grantsReceived = $totalAmount = $awardedGrants = $grantReportsReceived = 0; - $grantStatistics = array(); + $grantStatistics = array(); $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'); - $countries = CRM_Core_PseudoConstant::country(); - $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); + $countries = CRM_Core_PseudoConstant::country(); + $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); $grantAmountTotal = " SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , @@ -422,9 +393,9 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , } $values = CRM_Core_DAO::executeQuery($grantAmountAwarded); while ($values->fetch()) { - $awardedGrants = $values->count; + $awardedGrants = $values->count; $awardedGrantsAmount = $values->totalAmount; - $amountGranted = $values->grantedAmount; + $amountGranted = $values->grantedAmount; } foreach ($rows as $key => $values) { @@ -490,15 +461,19 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , } } - $totalStatistics['total_statistics'] = array('grants_received' => array('title' => ts('Grant Requests Received'), + $totalStatistics['total_statistics'] = array( + 'grants_received' => array( + 'title' => ts('Grant Requests Received'), 'count' => $grantsReceived, 'amount' => $totalAmount, ), - 'grants_awarded' => array('title' => ts('Grants Awarded'), + 'grants_awarded' => array( + 'title' => ts('Grants Awarded'), 'count' => $awardedGrants, 'amount' => $amountGranted, ), - 'grants_report_received' => array('title' => ts('Grant Reports Received'), + 'grants_report_received' => array( + 'title' => ts('Grant Reports Received'), 'count' => $grantReportsReceived, ), ); @@ -510,7 +485,8 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , $this->_outputMode == 'pdf' ) { $row = array(); - $this->_columnHeaders = array('civicrm_grant_total_grants' => array('title' => ts('Summary')), + $this->_columnHeaders = array( + 'civicrm_grant_total_grants' => array('title' => ts('Summary')), 'civicrm_grant_count' => array('title' => ts('Count')), 'civicrm_grant_amount' => array('title' => ts('Amount')), ); @@ -532,11 +508,13 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , foreach ($value['value'] as $field => $values) { foreach ($values['currency'] as $currency => $amount) { - $totalAmount[$currency] = $currency . $amount['value'] . "({$values['percentage']}%)"; + $totalAmount[$currency] = $currency . $amount['value'] . + "({$values['percentage']}%)"; } $totalAmt = implode(', ', $totalAmount); - $count = (boolean)CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : ''; - $row[] = array( + $count = (boolean) CRM_Utils_Array::value('count', $values, 0) ? + $values['count'] . " ({$values['percentage']}%)" : ''; + $row[] = array( 'civicrm_grant_total_grants' => $field, 'civicrm_grant_count' => $count, 'civicrm_grant_amount' => $totalAmt, @@ -557,7 +535,7 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , * @param bool $customData */ static function getStatistics(&$grantStatistics, $fieldValue, $values, - $awardedGrants, $awardedGrantsAmount, $customData = FALSE + $awardedGrants, $awardedGrantsAmount, $customData = FALSE ) { if (!$awardedGrantsAmount) { return; @@ -569,26 +547,34 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , if (!$customData) { if (!isset($grantStatistics['value'][$fieldValue]['currency'][$currency]) - || !isset($grantStatistics['value'][$fieldValue]['currency'][$currency]['value'])) { + || + !isset($grantStatistics['value'][$fieldValue]['currency'][$currency]['value']) + ) { $grantStatistics['value'][$fieldValue]['currency'][$currency]['value'] = 0; } $grantStatistics['value'][$fieldValue]['currency'][$currency]['value'] += $values['civicrm_grant_amount_total']; - $grantStatistics['value'][$fieldValue]['currency'][$currency]['percentage'] = round(($grantStatistics['value'][$fieldValue]['currency'][$currency]['value'] / $awardedGrantsAmount) * 100); + $grantStatistics['value'][$fieldValue]['currency'][$currency]['percentage'] = round(($grantStatistics['value'][$fieldValue]['currency'][$currency]['value'] / + $awardedGrantsAmount) * 100); if (!isset($grantStatistics['value'][$fieldValue]['count'])) { $grantStatistics['value'][$fieldValue]['count'] = 0; } $grantStatistics['value'][$fieldValue]['count']++; - $grantStatistics['value'][$fieldValue]['percentage'] = round(($grantStatistics['value'][$fieldValue]['count'] / $awardedGrants) * 100); + $grantStatistics['value'][$fieldValue]['percentage'] = round(($grantStatistics['value'][$fieldValue]['count'] / + $awardedGrants) * 100); } else { if (!isset($grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]) - || !isset($grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value'])) { + || + !isset($grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value']) + ) { $grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value'] = 0; } $grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value'] += $values['civicrm_grant_amount_total']; - $grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['percentage'] = round(($grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value'] / $awardedGrantsAmount) * 100); + $grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['percentage'] = round(($grantStatistics['value'][$fieldValue]['unassigned_currency'][$currency]['value'] / + $awardedGrantsAmount) * 100); $grantStatistics['value'][$fieldValue]['unassigned_count']++; - $grantStatistics['value'][$fieldValue]['unassigned_percentage'] = round(($grantStatistics['value'][$fieldValue]['unassigned_count'] / $awardedGrants) * 100); + $grantStatistics['value'][$fieldValue]['unassigned_percentage'] = round(($grantStatistics['value'][$fieldValue]['unassigned_count'] / + $awardedGrants) * 100); } } } diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index 47d9603f9c..da973a6e4e 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -44,7 +44,12 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { // just a toggle we use to build the from protected $_mailingidField = FALSE; - protected $_customGroupExtends = array('Contact', 'Individual', 'Household', 'Organization'); + protected $_customGroupExtends = array( + 'Contact', + 'Individual', + 'Household', + 'Organization' + ); protected $_charts = array( '' => 'Tabular', @@ -68,8 +73,7 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'title' => ts('Contact ID'), 'required' => TRUE, ), - 'sort_name' => - array( + 'sort_name' => array( 'title' => ts('Contact Name'), 'required' => TRUE, ), @@ -87,10 +91,12 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'no_display' => TRUE, ), ), - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'default' => TRUE, + 'default_order' => 'ASC' + ), ), 'grouping' => 'contact-fields', ); @@ -119,10 +125,8 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'operator' => 'like', ), ), - 'order_bys' => - array( - 'mailing_name' => - array( + 'order_bys' => array( + 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), ), @@ -137,10 +141,8 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'title' => ts('Bounce Reason'), ), ), - 'order_bys' => - array( - 'bounce_reason' => - array('title' => ts('Bounce Reason')), + 'order_bys' => array( + 'bounce_reason' => array('title' => ts('Bounce Reason')), ), 'grouping' => 'mailing-fields', ); @@ -163,10 +165,8 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'operator' => 'like', ), ), - 'order_bys' => - array( - 'bounce_name' => - array( + 'order_bys' => array( + 'bounce_name' => array( 'name' => 'name', 'title' => ts('Bounce Type'), ), @@ -183,10 +183,8 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 'required' => TRUE, ), ), - 'order_bys' => - array( - 'email' => - array('title' => ts('Email'), 'default_order' => 'ASC'), + 'order_bys' => array( + 'email' => array('title' => ts('Email'), 'default_order' => 'ASC'), ), 'grouping' => 'contact-fields', ); @@ -214,7 +212,9 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -320,7 +320,8 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { return; } - $chartInfo = array('legend' => ts('Mail Bounce Report'), + $chartInfo = array( + 'legend' => ts('Mail Bounce Report'), 'xname' => ts('Mailing'), 'yname' => ts('Bounce'), 'xLabelAngle' => 20, diff --git a/CRM/Report/Form/Mailing/Clicks.php b/CRM/Report/Form/Mailing/Clicks.php index 9fdda34531..6744c3cb0d 100644 --- a/CRM/Report/Form/Mailing/Clicks.php +++ b/CRM/Report/Form/Mailing/Clicks.php @@ -41,7 +41,12 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { protected $_phoneField = FALSE; - protected $_customGroupExtends = array('Contact', 'Individual', 'Household', 'Organization'); + protected $_customGroupExtends = array( + 'Contact', + 'Individual', + 'Household', + 'Organization' + ); protected $_charts = array( '' => 'Tabular', @@ -65,8 +70,7 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { 'title' => ts('Contact ID'), 'required' => TRUE, ), - 'sort_name' => - array( + 'sort_name' => array( 'title' => ts('Contact Name'), 'required' => TRUE, ), @@ -84,10 +88,12 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { 'no_display' => TRUE, ), ), - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'default' => TRUE, + 'default_order' => 'ASC' + ), ), 'grouping' => 'contact-fields', ); @@ -116,10 +122,8 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { 'operator' => 'like', ), ), - 'order_bys' => - array( - 'mailing_name' => - array( + 'order_bys' => array( + 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), ), @@ -152,10 +156,8 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { 'title' => ts('Click through URL'), ), ), - 'order_bys' => - array( - 'url' => - array('title' => ts('Click through URL')), + 'order_bys' => array( + 'url' => array('title' => ts('Click through URL')), ), 'grouping' => 'mailing-fields', ); @@ -176,7 +178,9 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -281,7 +285,8 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { return; } - $chartInfo = array('legend' => ts('Mail Clickthrough Report'), + $chartInfo = array( + 'legend' => ts('Mail Clickthrough Report'), 'xname' => ts('Mailing'), 'yname' => ts('Clicks'), 'xLabelAngle' => 20, diff --git a/CRM/Report/Form/Mailing/Detail.php b/CRM/Report/Form/Mailing/Detail.php index 8a182c971e..9305e13536 100644 --- a/CRM/Report/Form/Mailing/Detail.php +++ b/CRM/Report/Form/Mailing/Detail.php @@ -48,37 +48,30 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_contact'] = array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'id' => - array( + 'fields' => array( + 'id' => array( 'name' => 'id', 'title' => ts('Contact ID'), 'required' => TRUE, 'no_display' => TRUE, ), - 'sort_name' => - array( + 'sort_name' => array( 'title' => ts('Contact Name'), 'required' => TRUE, ), ), - 'filters' => - array( - 'sort_name' => - array( + 'filters' => array( + 'sort_name' => array( 'title' => ts('Contact Name'), ), - 'id' => - array( + 'id' => array( 'title' => ts('Contact ID'), 'no_display' => TRUE, ), ), - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC', ), @@ -88,19 +81,15 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_mailing'] = array( 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => - array( - 'mailing_name' => - array( + 'fields' => array( + 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), 'default' => TRUE, ), ), - 'filters' => - array( - 'mailing_id' => - array( + 'filters' => array( + 'mailing_id' => array( 'name' => 'id', 'title' => ts('Mailing'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -108,10 +97,8 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), ), ), - 'order_bys' => - array( - 'mailing_name' => - array( + 'order_bys' => array( + 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), ), @@ -126,19 +113,15 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_mailing_event_delivered'] = array( 'dao' => 'CRM_Mailing_Event_DAO_Delivered', - 'fields' => - array( - 'delivery_id' => - array( + 'fields' => array( + 'delivery_id' => array( 'name' => 'id', 'title' => ts('Delivery Status'), 'default' => TRUE, ), ), - 'filters' => - array( - 'delivery_status' => - array( + 'filters' => array( + 'delivery_status' => array( 'name' => 'delivery_status', 'title' => ts('Delivery Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, @@ -155,39 +138,41 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_mailing_event_unsubscribe'] = array( 'dao' => 'CRM_Mailing_Event_DAO_Unsubscribe', - 'fields' => - array( - 'unsubscribe_id' => - array( + 'fields' => array( + 'unsubscribe_id' => array( 'name' => 'id', 'title' => ts('Unsubscribe'), 'default' => TRUE, ), - 'optout_id' => - array( + 'optout_id' => array( 'name' => 'id', 'title' => ts('Opt-out'), 'default' => TRUE, 'alias' => 'mailing_event_unsubscribe_civireport2', ), ), - 'filters' => - array( - 'is_unsubscribed' => - array( + 'filters' => array( + 'is_unsubscribed' => array( 'name' => 'id', 'title' => ts('Unsubscribed'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')), + 'options' => array( + '' => ts('Any'), + '0' => ts('No'), + '1' => ts('Yes') + ), 'clause' => 'mailing_event_unsubscribe_civireport.id IS NULL', ), - 'is_optout' => - array( + 'is_optout' => array( 'title' => ts('Opted-out'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')), + 'options' => array( + '' => ts('Any'), + '0' => ts('No'), + '1' => ts('Yes') + ), 'clause' => 'mailing_event_unsubscribe_civireport2.id IS NULL', ), ), @@ -196,23 +181,23 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_mailing_event_reply'] = array( 'dao' => 'CRM_Mailing_Event_DAO_Reply', - 'fields' => - array( - 'reply_id' => - array( + 'fields' => array( + 'reply_id' => array( 'name' => 'id', 'title' => ts('Reply'), ), ), - 'filters' => - array( - 'is_replied' => - array( + 'filters' => array( + 'is_replied' => array( 'name' => 'id', 'title' => ts('Replied'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')), + 'options' => array( + '' => ts('Any'), + '0' => ts('No'), + '1' => ts('Yes') + ), 'clause' => 'mailing_event_reply_civireport.id IS NULL', ), ), @@ -221,23 +206,23 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_mailing_event_forward'] = array( 'dao' => 'CRM_Mailing_Event_DAO_Forward', - 'fields' => - array( - 'forward_id' => - array( + 'fields' => array( + 'forward_id' => array( 'name' => 'id', 'title' => ts('Forwarded to Email'), ), ), - 'filters' => - array( - 'is_forwarded' => - array( + 'filters' => array( + 'is_forwarded' => array( 'name' => 'id', 'title' => ts('Forwarded'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('' => ts('Any'), '0' => ts('No'), '1' => ts('Yes')), + 'options' => array( + '' => ts('Any'), + '0' => ts('No'), + '1' => ts('Yes') + ), 'clause' => 'mailing_event_forward_civireport.id IS NULL', ), ), @@ -246,10 +231,8 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { $this->_columns['civicrm_email'] = array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array( + 'fields' => array( + 'email' => array( 'title' => ts('Email'), 'required' => TRUE, ), @@ -274,9 +257,15 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if (in_array($fieldName, array( - 'unsubscribe_id', 'optout_id', 'forward_id', 'reply_id'))) { + 'unsubscribe_id', + 'optout_id', + 'forward_id', + 'reply_id' + ))) { $select[] = "IF({$field['dbAlias']} IS NULL, 'No', 'Yes') as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); @@ -329,10 +318,14 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { ON {$this->_aliases['civicrm_mailing_event_delivered']}.event_queue_id = civicrm_mailing_event_queue.id LEFT JOIN civicrm_mailing_event_bounce {$this->_aliases['civicrm_mailing_event_bounce']} ON {$this->_aliases['civicrm_mailing_event_bounce']}.event_queue_id = civicrm_mailing_event_queue.id"; - if (CRM_Utils_Array::value('delivery_status_value', $this->_params) == 'bounced') { + if (CRM_Utils_Array::value('delivery_status_value', $this->_params) == + 'bounced' + ) { $this->_columns['civicrm_mailing_event_delivered']['filters']['delivery_status']['clause'] = "{$this->_aliases['civicrm_mailing_event_bounce']}.id IS NOT NULL"; } - elseif (CRM_Utils_Array::value('delivery_status_value', $this->_params) == 'successful') { + elseif (CRM_Utils_Array::value('delivery_status_value', $this->_params) == + 'successful' + ) { $this->_columns['civicrm_mailing_event_delivered']['filters']['delivery_status']['clause'] = "{$this->_aliases['civicrm_mailing_event_delivered']}.id IS NOT NULL"; } } @@ -361,7 +354,8 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { if (array_key_exists('unsubscribe_id', $this->_params['fields']) || is_numeric(CRM_Utils_Array::value('is_unsubscribed_value', $this->_params)) ) { - if (CRM_Utils_Array::value('is_unsubscribed_value', $this->_params) == 1) { + if (CRM_Utils_Array::value('is_unsubscribed_value', $this->_params) == 1 + ) { $joinType = 'INNER'; $this->_columns['civicrm_mailing_event_unsubscribe']['filters']['is_unsubscribed']['clause'] = '(1)'; } @@ -439,9 +433,9 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { */ function mailingList() { - $data = array(); + $data = array(); $mailing = new CRM_Mailing_BAO_Mailing(); - $query = "SELECT name FROM civicrm_mailing "; + $query = "SELECT name FROM civicrm_mailing "; $mailing->query($query); while ($mailing->fetch()) { diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index 4a7b94df81..4033123659 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -41,7 +41,12 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { protected $_phoneField = FALSE; - protected $_customGroupExtends = array('Contact', 'Individual', 'Household', 'Organization'); + protected $_customGroupExtends = array( + 'Contact', + 'Individual', + 'Household', + 'Organization' + ); protected $_charts = array( '' => 'Tabular', @@ -65,8 +70,7 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { 'title' => ts('Contact ID'), 'required' => TRUE, ), - 'sort_name' => - array( + 'sort_name' => array( 'title' => ts('Contact Name'), 'required' => TRUE, ), @@ -84,18 +88,19 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { 'no_display' => TRUE, ), ), - 'order_bys' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'default' => TRUE, + 'default_order' => 'ASC' + ), ), 'grouping' => 'contact-fields', ); $this->_columns['civicrm_mailing'] = array( 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => - array( + 'fields' => array( 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), @@ -117,10 +122,8 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { 'operator' => 'like', ), ), - 'order_bys' => - array( - 'mailing_name' => - array( + 'order_bys' => array( + 'mailing_name' => array( 'name' => 'name', 'title' => ts('Mailing'), ), @@ -137,10 +140,8 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { 'required' => TRUE, ), ), - 'order_bys' => - array( - 'email' => - array('title' => ts('Email'), 'default_order' => 'ASC'), + 'order_bys' => array( + 'email' => array('title' => ts('Email'), 'default_order' => 'ASC'), ), 'grouping' => 'contact-fields', ); @@ -167,7 +168,9 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_email') { $this->_emailField = TRUE; } @@ -269,7 +272,8 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { return; } - $chartInfo = array('legend' => ts('Mail Opened Report'), + $chartInfo = array( + 'legend' => ts('Mail Opened Report'), 'xname' => ts('Mailing'), 'yname' => ts('Opened'), 'xLabelAngle' => 20, diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php index f11011479c..cffdc5a8b9 100644 --- a/CRM/Report/Form/Member/ContributionDetail.php +++ b/CRM/Report/Form/Member/ContributionDetail.php @@ -42,7 +42,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { protected $_allBatches = NULL; protected $_customGroupExtends = array( - 'Contribution', 'Membership'); + 'Contribution', + 'Membership' + ); /** * @@ -59,311 +61,284 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { asort($this->activeCampaigns); } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'first_name' => - array('title' => ts('First Name'), - 'no_repeat' => TRUE, - ), - 'last_name' => - array('title' => ts('Last Name'), - 'no_repeat' => TRUE, - ), - 'contact_type' => - array('title' => ts('Contact Type'), - 'no_repeat' => TRUE, - ), - 'contact_sub_type' => - array( - 'title' => ts('Contact Subtype'), - 'no_repeat' => TRUE, - ), - 'do_not_email' => - array('title' => ts('Do Not Email'), - 'no_repeat' => TRUE, - ), - 'is_opt_out' => - array('title' => ts('No Bulk Email(Is Opt Out)'), - 'no_repeat' => TRUE, - ), - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - 'csv_display' => TRUE, - 'title' => ts('Contact ID'), - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Donor Name'), - 'operator' => 'like', - ), - 'id' => - array('title' => ts('Contact ID'), - 'no_display' => TRUE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + 'no_repeat' => TRUE, + ), + 'last_name' => array( + 'title' => ts('Last Name'), + 'no_repeat' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + 'no_repeat' => TRUE, + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + 'no_repeat' => TRUE, + ), + 'do_not_email' => array( + 'title' => ts('Do Not Email'), + 'no_repeat' => TRUE, + ), + 'is_opt_out' => array( + 'title' => ts('No Bulk Email(Is Opt Out)'), + 'no_repeat' => TRUE, + ), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + 'csv_display' => TRUE, + 'title' => ts('Contact ID'), + ), ), - ), - 'grouping' => 'contact-fields', - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('title' => ts('Donor Email'), - 'default' => TRUE, - 'no_repeat' => TRUE, + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'operator' => 'like', + ), + 'id' => array( + 'title' => ts('Contact ID'), + 'no_display' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => - array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array( - 'phone' => - array('title' => ts('Donor Phone'), - 'default' => TRUE, - 'no_repeat' => TRUE, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Donor Email'), + 'default' => TRUE, + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - 'grouping' => 'contact-fields', - ), - 'first_donation' => array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'first_donation_date' => array( - 'title' => ts('First Contribution Date'), - 'base_field' => 'receive_date', - 'no_repeat' => TRUE, - ), - 'first_donation_amount' => array( - 'title' => ts('First Contribution Amount'), - 'base_field' => 'total_amount', - 'no_repeat' => TRUE, + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Donor Phone'), + 'default' => TRUE, + 'no_repeat' => TRUE, + ), ), + 'grouping' => 'contact-fields', ), - ), - 'civicrm_contribution' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'contribution_id' => array( - 'name' => 'id', - 'no_display' => TRUE, - 'required' => TRUE, - 'csv_display' => TRUE, - 'title' => ts('Contribution ID'), - ), - 'financial_type_id' => array('title' => ts('Financial Type'), - 'default' => TRUE, - ), - 'contribution_recur_id' => array('title' => ts('Recurring Contribution Id'), - 'name' => 'contribution_recur_id', - 'required' => TRUE, - 'no_display' => TRUE, - 'csv_display' => TRUE, - ), - 'contribution_status_id' => array('title' => ts('Contribution Status'), - ), - 'payment_instrument_id' => array('title' => ts('Payment Type'), - ), - 'contribution_source' => array( - 'name' => 'source', - 'title' => ts('Contribution Source'), - ), - 'currency' => array( - 'required' => TRUE, - 'no_display' => TRUE, - ), - 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), - 'receipt_date' => NULL, - 'fee_amount' => NULL, - 'net_amount' => NULL, - 'total_amount' => array('title' => ts('Amount'), - 'required' => TRUE, + 'first_donation' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'first_donation_date' => array( + 'title' => ts('First Contribution Date'), + 'base_field' => 'receive_date', + 'no_repeat' => TRUE, + ), + 'first_donation_amount' => array( + 'title' => ts('First Contribution Amount'), + 'base_field' => 'total_amount', + 'no_repeat' => TRUE, + ), ), ), - 'filters' => - array( - 'receive_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'financial_type_id' => - array('title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'payment_instrument_id' => - array('title' => ts('Payment Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), - ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'contribution_id' => array( + 'name' => 'id', + 'no_display' => TRUE, + 'required' => TRUE, + 'csv_display' => TRUE, + 'title' => ts('Contribution ID'), + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'default' => TRUE, + ), + 'contribution_recur_id' => array( + 'title' => ts('Recurring Contribution Id'), + 'name' => 'contribution_recur_id', + 'required' => TRUE, + 'no_display' => TRUE, + 'csv_display' => TRUE, + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + ), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), + ), + 'contribution_source' => array( + 'name' => 'source', + 'title' => ts('Contribution Source'), + ), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, + ), + 'trxn_id' => NULL, + 'receive_date' => array('default' => TRUE), + 'receipt_date' => NULL, + 'fee_amount' => NULL, + 'net_amount' => NULL, + 'total_amount' => array( + 'title' => ts('Amount'), + 'required' => TRUE, + ), ), - 'total_amount' => - array('title' => ts('Contribution Amount')), - ), - 'grouping' => 'contri-fields', - ), - 'civicrm_product' => - array( - 'dao' => 'CRM_Contribute_DAO_Product', - 'fields' => - array( - 'product_name' => array( - 'name' => 'name', - 'title' => ts('Premium'), + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'payment_instrument_id' => array( + 'title' => ts('Payment Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + ), + 'total_amount' => array('title' => ts('Contribution Amount')), ), + 'grouping' => 'contri-fields', ), - ), - 'civicrm_contribution_product' => - array( - 'dao' => 'CRM_Contribute_DAO_ContributionProduct', - 'fields' => - array( - 'product_id' => array( - 'no_display' => TRUE, - ), - 'product_option' => array( - 'title' => ts('Premium Option'), - ), - 'contribution_id' => array( - 'no_display' => TRUE, + 'civicrm_product' => array( + 'dao' => 'CRM_Contribute_DAO_Product', + 'fields' => array( + 'product_name' => array( + 'name' => 'name', + 'title' => ts('Premium'), + ), ), ), - ), - 'civicrm_contribution_ordinality' => - array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'alias' => 'cordinality', - 'filters' => - array( - 'ordinality' => - array('title' => ts('Contribution Ordinality'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array( - 0 => 'First by Contributor', - 1 => 'Second or Later by Contributor', + 'civicrm_contribution_product' => array( + 'dao' => 'CRM_Contribute_DAO_ContributionProduct', + 'fields' => array( + 'product_id' => array( + 'no_display' => TRUE, + ), + 'product_option' => array( + 'title' => ts('Premium Option'), + ), + 'contribution_id' => array( + 'no_display' => TRUE, ), ), ), - ), - 'civicrm_membership' => - array( - 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => - array( - 'membership_type_id' => array('title' => ts('Membership Type'), - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'membership_start_date' => array('title' => ts('Start Date'), - 'default' => TRUE, - ), - 'membership_end_date' => array('title' => ts('End Date'), - 'default' => TRUE, - ), - 'join_date' => array('title' => ts('Join Date'), - 'default' => TRUE, + 'civicrm_contribution_ordinality' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'alias' => 'cordinality', + 'filters' => array( + 'ordinality' => array( + 'title' => ts('Contribution Ordinality'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => array( + 0 => 'First by Contributor', + 1 => 'Second or Later by Contributor', + ), + ), ), - 'source' => array('title' => ts('Membership Source')), ), - 'filters' => array( - 'join_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_start_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_end_date' => - array('operatorType' => CRM_Report_Form::OP_DATE), - 'owner_membership_id' => - array('title' => ts('Membership Owner ID'), - 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'tid' => - array( - 'name' => 'membership_type_id', - 'title' => ts('Membership Types'), - 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Member_PseudoConstant::membershipType(), + 'civicrm_membership' => array( + 'dao' => 'CRM_Member_DAO_Membership', + 'fields' => array( + 'membership_type_id' => array( + 'title' => ts('Membership Type'), + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'membership_start_date' => array( + 'title' => ts('Start Date'), + 'default' => TRUE, + ), + 'membership_end_date' => array( + 'title' => ts('End Date'), + 'default' => TRUE, + ), + 'join_date' => array( + 'title' => ts('Join Date'), + 'default' => TRUE, + ), + 'source' => array('title' => ts('Membership Source')), + ), + 'filters' => array( + 'join_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'membership_start_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'membership_end_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'owner_membership_id' => array( + 'title' => ts('Membership Owner ID'), + 'operatorType' => CRM_Report_Form::OP_INT, + ), + 'tid' => array( + 'name' => 'membership_type_id', + 'title' => ts('Membership Types'), + 'type' => CRM_Utils_Type::T_INT, + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Member_PseudoConstant::membershipType(), + ), ), + 'grouping' => 'member-fields', ), - 'grouping' => 'member-fields', - ), - 'civicrm_membership_status' => - array( - 'dao' => 'CRM_Member_DAO_MembershipStatus', - 'alias' => 'mem_status', - 'fields' => - array( - 'membership_status_name' => - array( - 'name' => 'name', - 'title' => ts('Membership Status'), - 'default' => TRUE, + 'civicrm_membership_status' => array( + 'dao' => 'CRM_Member_DAO_MembershipStatus', + 'alias' => 'mem_status', + 'fields' => array( + 'membership_status_name' => array( + 'name' => 'name', + 'title' => ts('Membership Status'), + 'default' => TRUE, + ), ), - ), - 'filters' => array( - 'sid' => - array( - 'name' => 'id', - 'title' => ts('Membership Status'), - 'type' => CRM_Utils_Type::T_INT, - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), + 'filters' => array( + 'sid' => array( + 'name' => 'id', + 'title' => ts('Membership Status'), + 'type' => CRM_Utils_Type::T_INT, + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), + ), ), + 'grouping' => 'member-fields', ), - 'grouping' => 'member-fields', - ), - 'civicrm_note' => - array( - 'dao' => 'CRM_Core_DAO_Note', - 'fields' => - array( - 'contribution_note' => - array( - 'name' => 'note', - 'title' => ts('Contribution Note'), + 'civicrm_note' => array( + 'dao' => 'CRM_Core_DAO_Note', + 'fields' => array( + 'contribution_note' => array( + 'name' => 'note', + 'title' => ts('Contribution Note'), + ), ), - ), - 'filters' => - array( - 'note' => - array( - 'name' => 'note', - 'title' => ts('Contribution Note'), - 'operator' => 'like', - 'type' => CRM_Utils_Type::T_STRING, + 'filters' => array( + 'note' => array( + 'name' => 'note', + 'title' => ts('Contribution Note'), + 'operator' => 'like', + 'type' => CRM_Utils_Type::T_STRING, + ), ), ), - ), - ) + $this->addAddressFields(FALSE); + ) + $this->addAddressFields(FALSE); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -396,9 +371,10 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { 'title' => ts('Campaign'), 'default' => 'false', ); - $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $this->activeCampaigns, + $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $this->activeCampaigns, ); $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } @@ -418,7 +394,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } @@ -452,7 +430,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } } } - elseif ($fieldName == 'first_donation_date' || $fieldName == 'first_donation_amount') { + elseif ($fieldName == 'first_donation_date' || + $fieldName == 'first_donation_amount' + ) { $baseField = CRM_Utils_Array::value('base_field', $field); $select[] = "{$this->_aliases['civicrm_contribution']}.{$baseField} as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); @@ -487,7 +467,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { "; //for premiums - if (!empty($this->_params['fields']['product_name']) || !empty($this->_params['fields']['product_option'])) { + if (!empty($this->_params['fields']['product_name']) || + !empty($this->_params['fields']['product_option']) + ) { $this->_from .= " LEFT JOIN civicrm_contribution_product {$this->_aliases['civicrm_contribution_product']} ON ({$this->_aliases['civicrm_contribution_product']}.contribution_id = {$this->_aliases['civicrm_contribution']}.id) @@ -501,8 +483,10 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } // include contribution note - if (!empty($this->_params['fields']['contribution_note']) || !empty($this->_params['note_value'])) { - $this->_from.= " + if (!empty($this->_params['fields']['contribution_note']) || + !empty($this->_params['note_value']) + ) { + $this->_from .= " LEFT JOIN civicrm_note {$this->_aliases['civicrm_note']} ON ( {$this->_aliases['civicrm_note']}.entity_table = 'civicrm_contribution' AND {$this->_aliases['civicrm_contribution']}.id = {$this->_aliases['civicrm_note']}.entity_id )"; @@ -517,7 +501,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } //for contribution batches if ($this->_allBatches && - (!empty($this->_params['fields']['batch_id']) || !empty($this->_params['bid_value']))) { + (!empty($this->_params['fields']['batch_id']) || + !empty($this->_params['bid_value'])) + ) { $this->_from .= " LEFT JOIN civicrm_entity_financial_trxn tx ON (tx.entity_id = {$this->_aliases['civicrm_contribution']}.id AND tx.entity_table = 'civicrm_contribution') @@ -528,7 +514,10 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { ON {$this->_aliases['civicrm_batch']}.id = {$this->_aliases['civicrm_entity_batch']}.batch_id"; } - if ($this->_addressField OR (!empty($this->_params['state_province_id_value']) OR !empty($this->_params['country_id_value']))) { + if ($this->_addressField OR + (!empty($this->_params['state_province_id_value']) OR + !empty($this->_params['country_id_value'])) + ) { $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND @@ -605,7 +594,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { function orderBy() { $this->_orderBy = " ORDER BY {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_contact']}.id "; - if (!empty($this->_params['fields']['first_donation_date']) || !empty($this->_params['fields']['first_donation_amount'])) { + if (!empty($this->_params['fields']['first_donation_date']) || + !empty($this->_params['fields']['first_donation_amount']) + ) { $this->_orderBy .= ", {$this->_aliases['civicrm_contribution']}.receive_date"; } } @@ -626,8 +617,10 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { $dao = CRM_Core_DAO::executeQuery($sql); $totalAmount = $average = array(); while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)."(".$dao->count.")"; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $totalAmount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" . + $dao->count . ")"; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); } $statistics['counts']['amount'] = array( 'title' => ts('Total Amount'), @@ -657,8 +650,8 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { // custom code to alter rows $checkList = array(); - $entryFound = FALSE; - $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); + $entryFound = FALSE; + $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); @@ -677,25 +670,25 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } // allow repeat for first donation amount and date in csv - $fAmt = ''; + $fAmt = ''; $fDate = ''; foreach ($rows as $rowNum => $row) { if ($this->_outputMode == 'csv') { if (array_key_exists('civicrm_contact_id', $row)) { if ($contactId = $row['civicrm_contact_id']) { if ($rowNum == 0) { - $pcid = $contactId; - $fAmt = $row['first_donation_first_donation_amount']; + $pcid = $contactId; + $fAmt = $row['first_donation_first_donation_amount']; $fDate = $row['first_donation_first_donation_date']; } else { if ($pcid == $contactId) { $rows[$rowNum]['first_donation_first_donation_amount'] = $fAmt; - $rows[$rowNum]['first_donation_first_donation_date'] = $fDate; + $rows[$rowNum]['first_donation_first_donation_date'] = $fDate; $pcid = $contactId; } else { - $fAmt = $row['first_donation_first_donation_amount']; + $fAmt = $row['first_donation_first_donation_amount']; $fDate = $row['first_donation_first_donation_date']; $pcid = $contactId; } @@ -767,7 +760,8 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } // convert donor sort name to link - if (array_key_exists('civicrm_contact_sort_name', $row) && !empty($rows[$rowNum]['civicrm_contact_sort_name']) && + if (array_key_exists('civicrm_contact_sort_name', $row) && + !empty($rows[$rowNum]['civicrm_contact_sort_name']) && array_key_exists('civicrm_contact_id', $row) ) { $url = CRM_Utils_System::url('civicrm/contact/view', @@ -795,7 +789,9 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { CRM_Core_Permission::check('access CiviContribute') ) { $url = CRM_Utils_System::url('civicrm/contact/view/contribution', - 'reset=1&id=' . $row['civicrm_contribution_contribution_id'] . '&cid=' . $row['civicrm_contact_id'] . '&action=view&context=contribution&selectedChild=contribute', + 'reset=1&id=' . $row['civicrm_contribution_contribution_id'] . + '&cid=' . $row['civicrm_contact_id'] . + '&action=view&context=contribution&selectedChild=contribute', $this->_absoluteUrl ); $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url; diff --git a/CRM/Report/Form/Member/Lapse.php b/CRM/Report/Form/Member/Lapse.php index 42f5189b7b..9681590e0f 100644 --- a/CRM/Report/Form/Member/Lapse.php +++ b/CRM/Report/Form/Member/Lapse.php @@ -40,7 +40,8 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { protected $_phoneField = FALSE; protected $_charts = array('' => 'Tabular'); protected $_customGroupExtends = array( - 'Membership'); + 'Membership' + ); public $_drilldownReport = array('member/detail' => 'Link to Detail Report'); /** @@ -61,60 +62,50 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { } // UI for selecting columns to appear in the report list - // array conatining the columns, group_bys and filters build and provided to Form + // array containing the columns, group_bys and filters build and provided to Form $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Member Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Member Name'), 'no_repeat' => TRUE, 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'first_name' => - array('title' => ts('First Name'), + 'first_name' => array( + 'title' => ts('First Name'), 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'last_name' => - array('title' => ts('Last Name'), + 'last_name' => array( + 'title' => ts('Last Name'), 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), ), 'grouping' => 'contact-fields', ), - 'civicrm_membership_type' => - array( + 'civicrm_membership_type' => array( 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'filters' => - array( - 'tid' => - array( + 'filters' => array( + 'tid' => array( 'name' => 'id', 'title' => ts('Membership Types'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -122,76 +113,66 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { ), ), ), - 'civicrm_membership' => - array( + 'civicrm_membership' => array( 'dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', - 'fields' => - array( - 'membership_type_id' => - array( + 'fields' => array( + 'membership_type_id' => array( 'title' => 'Membership Type', 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING, ), - 'membership_start_date' => array('title' => ts('Current Cycle Start Date'), + 'membership_start_date' => array( + 'title' => ts('Current Cycle Start Date'), ), - 'membership_end_date' => array('title' => ts('Membership Lapse Date'), + 'membership_end_date' => array( + 'title' => ts('Membership Lapse Date'), 'required' => TRUE, ), ), - 'filters' => - array( - 'membership_end_date' => - array( + 'filters' => array( + 'membership_end_date' => array( 'title' => 'Lapsed Memberships', 'operatorType' => CRM_Report_Form::OP_DATE, ), ), ), - 'civicrm_membership_status' => - array( + 'civicrm_membership_status' => array( 'dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', - 'fields' => - array( - 'name' => array('title' => ts('Current Status'), + 'fields' => array( + 'name' => array( + 'title' => ts('Current Status'), 'required' => TRUE, ), ), 'grouping' => 'member-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), 'default' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone', - 'fields' => - array('phone' => NULL), + 'fields' => array('phone' => NULL), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array('email' => NULL), + 'fields' => array('email' => NULL), 'grouping' => 'contact-fields', ), ); @@ -202,7 +183,8 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { 'title' => 'Campaign', 'default' => 'false', ); - $this->_columns['civicrm_membership']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_membership']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -223,7 +205,9 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // to include optional columns address ,email and phone only if checked if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; @@ -306,8 +290,8 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { if ($field['operatorType'] & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -332,11 +316,13 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { } if (empty($clauses)) { - $this->_where = "WHERE end_date < '" . date('Y-m-d') . "' AND {$this->_aliases['civicrm_membership_status']}.name = 'Expired'"; + $this->_where = "WHERE end_date < '" . date('Y-m-d') . + "' AND {$this->_aliases['civicrm_membership_status']}.name = 'Expired'"; } else { if (!array_key_exists('end_date', $clauses)) { - $this->_where = "WHERE end_date < '" . date('Y-m-d') . "' AND " . implode(' AND ', $clauses); + $this->_where = "WHERE end_date < '" . date('Y-m-d') . "' AND " . + implode(' AND ', $clauses); } else { $this->_where = "WHERE " . implode(' AND ', $clauses); @@ -359,8 +345,8 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { $this->buildACLClause($this->_aliases['civicrm_contact']); $sql = $this->buildQuery(TRUE); - $dao = CRM_Core_DAO::executeQuery($sql); - $rows = $graphRows = array(); + $dao = CRM_Core_DAO::executeQuery($sql); + $rows = $graphRows = array(); $count = 0; while ($dao->fetch()) { $row = array(); diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index cc01e69dec..a7528801da 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -59,7 +59,7 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { // Array containing the columns, group_bys and filters build and provided to Form // Check if CiviCampaign is a) enabled and b) has active campaigns - $config = CRM_Core_Config::singleton(); + $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); @@ -68,121 +68,105 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_membership' => - array( + 'civicrm_membership' => array( 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'fields' => - array( - 'membership_type_id' => - array( + 'fields' => array( + 'membership_type_id' => array( 'title' => 'Membership Type', 'required' => TRUE, ), ), - 'filters' => - array( - 'join_date' => - array('title' => ts('Member Since'), + 'filters' => array( + 'join_date' => array( + 'title' => ts('Member Since'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'membership_start_date' => - array( + 'membership_start_date' => array( 'name' => 'start_date', 'title' => ts('Membership Start Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'membership_end_date' => - array( + 'membership_end_date' => array( 'name' => 'end_date', 'title' => ts('Membership End Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'owner_membership_id' => - array('title' => ts('Membership Owner ID'), + 'owner_membership_id' => array( + 'title' => ts('Membership Owner ID'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, ), - 'membership_type_id' => - array('title' => ts('Membership Type'), + 'membership_type_id' => array( + 'title' => ts('Membership Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), ), - 'status_id' => - array('title' => ts('Membership Status'), + 'status_id' => array( + 'title' => ts('Membership Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), ), ), - 'group_bys' => - array( - 'join_date' => - array('title' => ts('Member Since'), + 'group_bys' => array( + 'join_date' => array( + 'title' => ts('Member Since'), 'default' => TRUE, 'frequency' => TRUE, 'chart' => TRUE, 'type' => 12, ), - 'membership_type_id' => - array( + 'membership_type_id' => array( 'title' => 'Membership Type', 'default' => TRUE, 'chart' => TRUE, ), ), ), - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'contact_id' => - array( + 'fields' => array( + 'contact_id' => array( 'no_display' => TRUE, ), - 'contact_type' => - array( + 'contact_type' => array( 'title' => ts('Contact Type'), ), - 'contact_sub_type' => - array( + 'contact_sub_type' => array( 'title' => ts('Contact Subtype'), ), ), ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => - array( - 'currency' => - array('required' => TRUE, + 'fields' => array( + 'currency' => array( + 'required' => TRUE, 'no_display' => TRUE, ), - 'total_amount' => - array('title' => ts('Amount Statistics'), + 'total_amount' => array( + 'title' => ts('Amount Statistics'), 'required' => TRUE, - 'statistics' => - array('sum' => ts('Total Payments Made'), + 'statistics' => array( + 'sum' => ts('Total Payments Made'), 'count' => ts('Contribution Count'), 'avg' => ts('Average'), ), ), ), - 'filters' => - array( - 'currency' => - array('title' => 'Currency', + 'filters' => array( + 'currency' => array( + 'title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, ), - 'contribution_status_id' => - array('title' => ts('Contribution Status'), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), ), @@ -198,7 +182,8 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { 'title' => 'Campaign', 'default' => 'false', ); - $this->_columns['civicrm_membership']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_membership']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -218,7 +203,8 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { $this->_columnHeaders = array(); $select[] = " COUNT( DISTINCT {$this->_aliases['civicrm_membership']}.id ) as civicrm_membership_member_count"; $select['joinDate'] = " {$this->_aliases['civicrm_membership']}.join_date as civicrm_membership_member_join_date"; - $this->_columnHeaders["civicrm_membership_member_join_date"] = array('title' => ts('Member Since'), + $this->_columnHeaders["civicrm_membership_member_join_date"] = array( + 'title' => ts('Member Since'), 'type' => CRM_Utils_Type::T_DATE, ); foreach ($this->_columns as $tableName => $table) { @@ -230,35 +216,36 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { case 'YEARWEEK': $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL WEEKDAY({$field['dbAlias']}) DAY) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "YEARWEEK({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "WEEKOFYEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Week'; break; case 'YEAR': - $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "MAKEDATE(YEAR({$field['dbAlias']}), 1) AS {$tableName}_{$fieldName}_start"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "YEAR({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Year'; break; case 'MONTH': - $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; - $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "DATE_SUB({$field['dbAlias']}, INTERVAL (DAYOFMONTH({$field['dbAlias']})-1) DAY) as {$tableName}_{$fieldName}_start"; + $select[] = "MONTH({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "MONTHNAME({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Month'; break; case 'QUARTER': - $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; - $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; + $select[] = "STR_TO_DATE(CONCAT( 3 * QUARTER( {$field['dbAlias']} ) -2 , '/', '1', '/', YEAR( {$field['dbAlias']} ) ), '%m/%d/%Y') AS {$tableName}_{$fieldName}_start"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_subtotal"; + $select[] = "QUARTER({$field['dbAlias']}) AS {$tableName}_{$fieldName}_interval"; $field['title'] = 'Quarter'; break; } if (!empty($this->_params['group_bys_freq'][$fieldName])) { $this->_interval = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning'; + $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = + $field['title'] . ' Beginning'; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type']; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName]; @@ -276,7 +263,9 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // only include statistics columns if set if (!empty($field['statistics'])) { @@ -307,7 +296,9 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } } elseif ($fieldName == 'membership_type_id') { - if (empty($this->_params['group_bys']['membership_type_id']) && !empty($this->_params['group_bys']['join_date'])) { + if (empty($this->_params['group_bys']['membership_type_id']) && + !empty($this->_params['group_bys']['join_date']) + ) { $select[] = "GROUP_CONCAT(DISTINCT {$field['dbAlias']} ORDER BY {$field['dbAlias']} ) as {$tableName}_{$fieldName}"; } else { @@ -324,7 +315,8 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } } } - $this->_columnHeaders["civicrm_membership_member_count"] = array('title' => ts('Member Count'), + $this->_columnHeaders["civicrm_membership_member_count"] = array( + 'title' => ts('Member Count'), 'type' => CRM_Utils_Type::T_INT, ); } @@ -349,6 +341,7 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} ON payment.contribution_id = {$this->_aliases['civicrm_contribution']}.id"; } + // end of from function where() { @@ -369,12 +362,14 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { if (!empty($field['chart'])) { $this->assign('chartSupported', TRUE); } - if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params['group_bys_freq'][$fieldName])) { + if (!empty($table['group_bys'][$fieldName]['frequency']) && + !empty($this->_params['group_bys_freq'][$fieldName]) + ) { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') - )) { + array('year') + )) { $append = ''; } $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})"; @@ -389,7 +384,8 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } $this->_rollup = ' WITH ROLLUP'; - $this->_groupBy = 'GROUP BY ' . implode(', ', $this->_groupBy) . " {$this->_rollup} "; + $this->_groupBy = 'GROUP BY ' . implode(', ', $this->_groupBy) . + " {$this->_rollup} "; } else { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_membership']}.join_date"; @@ -420,8 +416,10 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $totalAmount = $average = array(); $count = $memberCount = 0; while ($dao->fetch()) { - $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)."(".$dao->count.")"; - $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); + $totalAmount[] = + CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" . + $dao->count . ")"; + $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; $memberCount += $dao->memberCount; } @@ -444,7 +442,7 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency 'type' => CRM_Utils_Type::T_STRING, ); - if (!(int)$statistics['counts']['amount']['value']) { + if (!(int) $statistics['counts']['amount']['value']) { //if total amount is zero then hide Chart Options $this->assign('chartSupported', FALSE); } @@ -468,8 +466,9 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency if (!empty($this->_params['charts'])) { foreach ($rows as $key => $row) { if (!($row['civicrm_membership_join_date_subtotal'] && - $row['civicrm_membership_membership_type_id'] - )) { + $row['civicrm_membership_membership_type_id'] + ) + ) { continue; } if ($isMembershipType) { @@ -497,7 +496,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $displayRange = $year; break; } - $membershipType = $displayRange . "-" . $membershipTypeValues[$row['civicrm_membership_membership_type_id']]; + $membershipType = $displayRange . "-" . + $membershipTypeValues[$row['civicrm_membership_membership_type_id']]; } else { @@ -540,40 +540,41 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $entryFound = FALSE; foreach ($rows as $rowNum => $row) { // make count columns point to detail report - if (!empty($this->_params['group_bys']['join_date']) && !empty($row['civicrm_membership_join_date_start']) && + if (!empty($this->_params['group_bys']['join_date']) && + !empty($row['civicrm_membership_join_date_start']) && $row['civicrm_membership_join_date_start'] && $row['civicrm_membership_join_date_subtotal'] ) { $dateStart = CRM_Utils_Date::customFormat($row['civicrm_membership_join_date_start'], '%Y%m%d'); - $endDate = new DateTime($dateStart); - $dateEnd = array(); + $endDate = new DateTime($dateStart); + $dateEnd = array(); list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d')); switch (strtolower($this->_params['group_bys_freq']['join_date'])) { case 'month': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 1, - $dateEnd['d'] - 1, $dateEnd['Y'] - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + )); break; case 'year': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], - $dateEnd['d'] - 1, $dateEnd['Y'] + 1 - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + 1 + )); break; case 'yearweek': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'], - $dateEnd['d'] + 6, $dateEnd['Y'] - )); + $dateEnd['d'] + 6, $dateEnd['Y'] + )); break; case 'quarter': $dateEnd = date("Ymd", mktime(0, 0, 0, $dateEnd['M'] + 3, - $dateEnd['d'] - 1, $dateEnd['Y'] - )); + $dateEnd['d'] - 1, $dateEnd['Y'] + )); break; } $typeUrl = ''; @@ -584,7 +585,8 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency } $statusUrl = ''; if (!empty($this->_params['status_id_value'])) { - $statusUrl = "&sid_op=in&sid_value=" . implode(",", $this->_params['status_id_value']); + $statusUrl = "&sid_op=in&sid_value=" . + implode(",", $this->_params['status_id_value']); } $url = CRM_Report_Utils_Report::getNextUrl('member/detail', "reset=1&force=1&join_date_from={$dateStart}&join_date_to={$dateEnd}{$typeUrl}{$statusUrl}", diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index d75056a672..ea0110c914 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -53,40 +53,32 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { // UI for selecting columns to appear in the report list // array conatining the columns, group_bys and filters build and provided to Form $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Member Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Member Name'), 'no_repeat' => TRUE, 'required' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), - 'group_bys' => - array( - 'id' => - array('title' => ts('Contact ID')), - 'display_name' => - array('title' => ts('Contact Name'), + 'group_bys' => array( + 'id' => array('title' => ts('Contact ID')), + 'display_name' => array( + 'title' => ts('Contact Name'), ), ), 'grouping' => 'contact-fields', ), - 'civicrm_membership_type' => - array( + 'civicrm_membership_type' => array( 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'filters' => - array( - 'gid' => - array( + 'filters' => array( + 'gid' => array( 'name' => 'id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM, @@ -94,66 +86,55 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { ), ), ), - 'civicrm_membership' => - array( + 'civicrm_membership' => array( 'dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', - 'fields' => - array( - 'membership_type_id' => - array( + 'fields' => array( + 'membership_type_id' => array( 'title' => 'Membership Type', 'required' => TRUE, ), 'join_date' => NULL, - 'start_date' => array('title' => ts('Current Cycle Start Date'), + 'start_date' => array( + 'title' => ts('Current Cycle Start Date'), ), - 'end_date' => array('title' => ts('Current Cycle End Date'), + 'end_date' => array( + 'title' => ts('Current Cycle End Date'), ), ), - 'group_bys' => - array( - 'membership_type_id' => - array('title' => ts('Membership Type')), + 'group_bys' => array( + 'membership_type_id' => array('title' => ts('Membership Type')), ), - 'filters' => - array( - 'join_date' => - array('type' => CRM_Utils_Type::T_DATE), + 'filters' => array( + 'join_date' => array('type' => CRM_Utils_Type::T_DATE), ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), 'default' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array('email' => NULL), + 'fields' => array('email' => NULL), 'grouping' => 'contact-fields', ), - 'civicrm_contribution' => - array( + 'civicrm_contribution' => array( 'dao' => 'CRM_Contribute_DAO_Contribution', - 'filters' => - array( - 'total_amount' => - array('title' => ts('Contribution Amount'), + 'filters' => array( + 'total_amount' => array( + 'title' => ts('Contribution Amount'), ), ), ), @@ -179,7 +160,9 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // to include optional columns address and email, only if checked if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; @@ -244,8 +227,8 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} $clause = NULL; if ($field['type'] & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to); @@ -285,7 +268,8 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} */ function statistics(&$rows) { $statistics = array(); - $statistics[] = array('title' => ts('Row(s) Listed'), + $statistics[] = array( + 'title' => ts('Row(s) Listed'), 'value' => count($rows), ); return $statistics; @@ -311,7 +295,8 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} ) { $this->_rollup = " WITH ROLLUP"; } - $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . " {$this->_rollup} "; + $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . + " {$this->_rollup} "; } else { $this->_groupBy = "GROUP BY contact.id"; @@ -339,8 +324,8 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; - $dao = CRM_Core_DAO::executeQuery($sql); - $rows = $graphRows = array(); + $dao = CRM_Core_DAO::executeQuery($sql); + $rows = $graphRows = array(); $count = 0; while ($dao->fetch()) { $row = array(); @@ -367,7 +352,10 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} if (!empty($this->_params['charts'])) { foreach (array( - 'receive_date', $this->_interval, 'value') as $ignore) { + 'receive_date', + $this->_interval, + 'value' + ) as $ignore) { unset($graphRows[$ignore][$count - 1]); } @@ -437,7 +425,8 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'], $this->_absoluteUrl ); - $rows[$rowNum]['civicrm_contact_sort_name'] = "" . $row["civicrm_contact_sort_name"] . ''; + $rows[$rowNum]['civicrm_contact_sort_name'] = + "" . $row["civicrm_contact_sort_name"] . ''; $entryFound = TRUE; } diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index 1c622ee20e..f12fdfa30b 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -26,15 +26,15 @@ */ - /* - * !!!!!!!!!!!!!!!!!!!! - * NB: this is named detail but behaves like a summary report. - * It is also accessed through the Pledge Summary link in the UI - * This should presumably be changed. - * ~ Doten - * !!!!!!!!!!!!!!!!!!!! - * - */ +/* + * !!!!!!!!!!!!!!!!!!!! + * NB: this is named detail but behaves like a summary report. + * It is also accessed through the Pledge Summary link in the UI + * This should presumably be changed. + * ~ Doten + * !!!!!!!!!!!!!!!!!!!! + * + */ /** * @@ -60,9 +60,9 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { * */ function __construct() { - $this->_pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus(); - // Check if CiviCampaign is a) enabled and b) has active campaigns - $config = CRM_Core_Config::singleton(); + $this->_pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus(); + // Check if CiviCampaign is a) enabled and b) has active campaigns + $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); @@ -71,145 +71,126 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name')), - 'id' => - array('no_display' => TRUE), - ), - 'grouping' => 'contact-fields', - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array('no_repeat' => TRUE), - ), - 'grouping' => 'contact-fields', - ), - 'civicrm_pledge' => - array( - 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => - array( - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'contact_id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'amount' => - array('title' => ts('Pledge Amount'), - 'required' => TRUE, - 'type' => CRM_Utils_Type::T_MONEY, - ), - 'currency' => - array( - 'required' => TRUE, - 'no_display' => TRUE, - ), - 'frequency_unit' => - array('title' => ts('Frequency Unit'), - ), - 'installments' => - array('title' => ts('Installments'), - ), - 'pledge_create_date' => - array('title' => ts('Pledge Made Date'), - ), - 'start_date' => - array('title' => ts('Pledge Start Date'), - 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => - array('title' => ts('Pledge End Date'), - 'type' => CRM_Utils_Type::T_DATE, + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'required' => TRUE, + 'no_repeat' => TRUE, + ), ), - 'status_id' => - array('title' => ts('Pledge Status'), - 'required' => TRUE, + 'filters' => array( + 'sort_name' => array('title' => ts('Contact Name')), + 'id' => array('no_display' => TRUE), ), + 'grouping' => 'contact-fields', ), - 'filters' => - array( - 'pledge_create_date' => - array( - 'title' => 'Pledge Made Date', - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'pledge_amount' => - array('title' => ts('Pledged Amount'), - 'operatorType' => CRM_Report_Form::OP_INT, + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array('no_repeat' => TRUE), ), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'sid' => - array( - 'name' => 'status_id', - 'title' => ts('Pledge Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('contribution_status'), + 'grouping' => 'contact-fields', + ), + 'civicrm_pledge' => array( + 'dao' => 'CRM_Pledge_DAO_Pledge', + 'fields' => array( + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'contact_id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'amount' => array( + 'title' => ts('Pledge Amount'), + 'required' => TRUE, + 'type' => CRM_Utils_Type::T_MONEY, + ), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, + ), + 'frequency_unit' => array( + 'title' => ts('Frequency Unit'), + ), + 'installments' => array( + 'title' => ts('Installments'), + ), + 'pledge_create_date' => array( + 'title' => ts('Pledge Made Date'), + ), + 'start_date' => array( + 'title' => ts('Pledge Start Date'), + 'type' => CRM_Utils_Type::T_DATE, + ), + 'end_date' => array( + 'title' => ts('Pledge End Date'), + 'type' => CRM_Utils_Type::T_DATE, + ), + 'status_id' => array( + 'title' => ts('Pledge Status'), + 'required' => TRUE, + ), ), + 'filters' => array( + 'pledge_create_date' => array( + 'title' => 'Pledge Made Date', + 'operatorType' => CRM_Report_Form::OP_DATE, + ), + 'pledge_amount' => array( + 'title' => ts('Pledged Amount'), + 'operatorType' => CRM_Report_Form::OP_INT, + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'sid' => array( + 'name' => 'status_id', + 'title' => ts('Pledge Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('contribution_status'), + ), + ), ), - ), - 'civicrm_pledge_payment' => - array( - 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => - array( - 'total_paid' => - array( + 'civicrm_pledge_payment' => array( + 'dao' => 'CRM_Pledge_DAO_PledgePayment', + 'fields' => array( + 'total_paid' => array( 'title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_MONEY, ), - 'balance_due' => - array( + 'balance_due' => array( 'title' => ts('Balance Due'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, ), + ), ), - ), - ) - + $this->getAddressColumns(array('group_by' => FALSE)) - + $this->getPhoneColumns(); + ) + + $this->getAddressColumns(array('group_by' => FALSE)) + + $this->getPhoneColumns(); // If we have a campaign, build out the relevant elements $this->_tagFilter = TRUE; if ($campaignEnabled && !empty($this->activeCampaigns)) { - $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array( - 'title' => 'Campaign', - 'default' => 'false', - ); - $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => $this->activeCampaigns, - ); - $this->_columns['civicrm_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign')); + $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array( + 'title' => 'Campaign', + 'default' => 'false', + ); + $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => $this->activeCampaigns, + ); + $this->_columns['civicrm_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign')); } @@ -238,7 +219,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { * @return bool|string */ function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { - if($fieldName == 'total_paid'){ + if ($fieldName == 'total_paid') { $this->_totalPaid = TRUE; // add pledge_payment join $this->_columnHeaders["{$tableName}_{$fieldName}"] = array( 'title' => $field['title'], @@ -246,7 +227,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { ); return "COALESCE(sum({$this->_aliases[$tableName]}.actual_amount), 0) as {$tableName}_{$fieldName}"; } - if($fieldName == 'balance_due'){ + if ($fieldName == 'balance_due') { $cancelledStatus = array_search('Cancelled', $this->_pledgeStatuses); $completedStatus = array_search('Completed', $this->_pledgeStatuses); $this->_totalPaid = TRUE; // add pledge_payment join @@ -255,7 +236,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { '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 "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; } @@ -263,9 +244,10 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { function groupBy() { parent::groupBy(); if (empty($this->_groupBy) && $this->_totalPaid) { - $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_pledge']}.id, {$this->_aliases['civicrm_pledge']}.currency" ; + $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_pledge']}.id, {$this->_aliases['civicrm_pledge']}.currency"; } } + function from() { $this->_from = " FROM civicrm_pledge {$this->_aliases['civicrm_pledge']} @@ -274,7 +256,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { {$this->_aliases['civicrm_pledge']}.contact_id ) {$this->_aclFrom} "; - if($this->_totalPaid){ + if ($this->_totalPaid) { $this->_from .= " LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']} ON {$this->_aliases['civicrm_pledge']}.id = {$this->_aliases['civicrm_pledge_payment']}.pledge_id @@ -301,7 +283,7 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { */ function statistics(&$rows) { $statistics = parent::statistics($rows); - //regenerate the from field without extra left join on pledge payments + //regenerate the from field without extra left join on pledge payments $this->_totalPaid = FALSE; $this->from(); $this->customDataFrom(); @@ -320,9 +302,9 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $dao = CRM_Core_DAO::executeQuery($sql); $count = $index = $totalCount = 0; // this will run once per currency - while($dao->fetch()) { + while ($dao->fetch()) { $totalAmount = CRM_Utils_Money::format($dao->amount, $dao->currency); - $average = CRM_Utils_Money::format($dao->avg, $dao->currency); + $average = CRM_Utils_Money::format($dao->avg, $dao->currency); $count = $dao->count; $totalCount .= $count; $statistics['counts']['amount' . $index] = array( @@ -340,9 +322,9 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 'value' => $count, 'type' => CRM_Utils_Type::T_INT, ); - $index ++; + $index++; } - if($totalCount > $count) { + if ($totalCount > $count) { $statistics['counts']['count' . $index] = array( 'title' => ts('Total No Pledges'), 'value' => $totalCount, @@ -365,8 +347,8 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -415,8 +397,8 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { // get the acl clauses built before we assemble the query $this->buildACLClause($this->_aliases['civicrm_contact']); - $sql = $this->buildQuery(); - $rows = $payment = array(); + $sql = $this->buildQuery(); + $rows = $payment = array(); $dao = CRM_Core_DAO::executeQuery($sql); @@ -439,27 +421,27 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $this->_columnHeaders['scheduled_date'] = array( 'type' => CRM_Utils_Type::T_DATE, 'title' => 'Next Payment Due', - ); - $this->_columnHeaders['scheduled_amount'] = array( - 'type' => CRM_Utils_Type::T_MONEY, - 'title' => 'Next Payment Amount', - ); - $this->_columnHeaders['status_id'] = NULL; - - /* - * this is purely about ordering the total paid & balance due fields off to the end - * of the table in case custom or address fields cause them to fall in the middle - * (arguably the pledge amount should be moved to after these fields too) - * - */ - $tableHeaders = array( - 'civicrm_pledge_payment_total_paid', - 'civicrm_pledge_payment_balance_due' - ); + ); + $this->_columnHeaders['scheduled_amount'] = array( + 'type' => CRM_Utils_Type::T_MONEY, + 'title' => 'Next Payment Amount', + ); + $this->_columnHeaders['status_id'] = NULL; + + /* + * this is purely about ordering the total paid & balance due fields off to the end + * of the table in case custom or address fields cause them to fall in the middle + * (arguably the pledge amount should be moved to after these fields too) + * + */ + $tableHeaders = array( + '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 - if(isset($this->_columnHeaders[$header])){ + if (isset($this->_columnHeaders[$header])) { $headervalue = $this->_columnHeaders[$header]; unset($this->_columnHeaders[$header]); $this->_columnHeaders[$header] = $headervalue; @@ -524,8 +506,8 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { */ function alterDisplay(&$rows) { // custom code to alter rows - $entryFound = FALSE; - $checkList = array(); + $entryFound = FALSE; + $checkList = array(); $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index d5b779964d..a5a047d38a 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -41,7 +41,8 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { public $_drilldownReport = array('pledge/summary' => 'Link to Detail Report'); protected $_customGroupExtends = array( - 'Pledge'); + 'Pledge' + ); /** * @@ -61,88 +62,76 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Constituent Name'), + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Constituent Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), - 'id' => - array( + 'id' => array( 'no_display' => TRUE, 'required' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_pledge' => - array( + 'civicrm_pledge' => array( 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => - array( - 'pledge_create_date' => - array('title' => ts('Pledge Made'), + 'fields' => array( + 'pledge_create_date' => array( + 'title' => ts('Pledge Made'), 'required' => TRUE, ), - 'financial_type_id' => - array('title' => ts('Financial Type'), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), 'requried' => TRUE, ), - 'amount' => - array('title' => ts('Amount'), + 'amount' => array( + 'title' => ts('Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, ), - 'currency' => - array( + 'currency' => array( 'required' => TRUE, 'no_display' => TRUE, ), - 'status_id' => - array('title' => ts('Status'), + 'status_id' => array( + 'title' => ts('Status'), ), ), - 'filters' => - array( - 'pledge_create_date' => - array( + 'filters' => array( + 'pledge_create_date' => array( 'title' => ts('Pledge Made'), 'operatorType' => CRM_Report_Form::OP_DATE, ), - 'currency' => - array('title' => 'Currency', + 'currency' => array( + 'title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, ), - '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(), + 'options' => CRM_Contribute_PseudoConstant::financialType(), ), ), 'grouping' => 'pledge-fields', ), - 'civicrm_pledge_payment' => - array( + 'civicrm_pledge_payment' => array( 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => - array( + 'fields' => array( 'scheduled_date' => array( 'title' => ts('Next Payment Due'), 'type' => CRM_Utils_Type::T_DATE, 'required' => TRUE, ), ), - 'filters' => - array( - 'scheduled_date' => - array( + 'filters' => array( + 'scheduled_date' => array( 'title' => ts('Next Payment Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, @@ -150,39 +139,32 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { ), 'grouping' => 'pledge-fields', ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( + 'fields' => array( 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), 'default' => TRUE, ), ), 'grouping' => 'contact-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array('email' => NULL), + 'fields' => array('email' => NULL), 'grouping' => 'contact-fields', ), - 'civicrm_group' => - array( + 'civicrm_group' => array( 'dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', - 'filters' => - array( - 'gid' => - array( + 'filters' => array( + 'gid' => array( 'name' => 'group_id', 'title' => ts('Group'), 'group' => TRUE, @@ -199,7 +181,8 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { 'title' => 'Campaign', 'default' => 'false', ); - $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'), + $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array( + 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, ); @@ -221,7 +204,9 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { // to include optional columns address and email, only if checked if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; @@ -246,7 +231,10 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $pendingStatus = array_search('Pending', $allStatus); foreach (array( - 'Pending', 'In Progress', 'Overdue') as $statusKey) { + 'Pending', + 'In Progress', + 'Overdue' + ) as $statusKey) { if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) { $unpaidStatus[] = $key; } @@ -305,8 +293,8 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { */ function alterDisplay(&$rows) { // custom code to alter rows - $entryFound = FALSE; - $checkList = array(); + $entryFound = FALSE; + $checkList = array(); $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { @@ -344,7 +332,7 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { if (array_key_exists('civicrm_pledge_financial_type_id', $row)) { if ($value = $row['civicrm_pledge_financial_type_id']) { $rows[$rowNum]['civicrm_pledge_financial_type_id'] = - CRM_Contribute_PseudoConstant::financialType($value, false); + CRM_Contribute_PseudoConstant::financialType($value, FALSE); } $entryFound = TRUE; } diff --git a/CRM/Report/Form/Pledge/Summary.php b/CRM/Report/Form/Pledge/Summary.php index 35fcc785cf..c9222ca321 100644 --- a/CRM/Report/Form/Pledge/Summary.php +++ b/CRM/Report/Form/Pledge/Summary.php @@ -50,147 +50,127 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), - 'no_repeat' => TRUE, - ), - 'postal_greeting_display' => - array('title' => ts('Postal Greeting')), - 'id' => - array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - ), - 'grouping' => 'contact-fields', - 'group_bys' => - array( - 'id' => - array('title' => ts('Contact ID')), - 'sort_name' => - array('title' => ts('Contact Name'), - ), - ), - ), - 'civicrm_email' => - array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array( - 'email' => - array( - 'no_repeat' => TRUE, - 'title' => ts('email'), - ), - ), - 'grouping' => 'contact-fields', - ), - 'civicrm_pledge' => - array( - 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => - array( - 'id' => - array( - 'no_display' => TRUE, - 'required' => FALSE, - ), - 'currency' => array( - 'required' => TRUE, - 'no_display' => TRUE, - ), - 'amount' => - array('title' => ts('Pledge Amount'), - 'required' => TRUE, - 'type' => CRM_Utils_Type::T_MONEY, - 'statistics' => - array('sum' => ts('Aggregate Amount Pledged'), - 'count' => ts('Pledges'), - 'avg' => ts('Average'), + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'no_repeat' => TRUE, + ), + 'postal_greeting_display' => array('title' => ts('Postal Greeting')), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, ), ), - 'frequency_unit' => - array('title' => ts('Frequency Unit'), - ), - 'installments' => - array('title' => ts('Installments'), - ), - 'pledge_create_date' => - array('title' => ts('Pledge Made Date'), - ), - 'start_date' => - array('title' => ts('Pledge Start Date'), - 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => - array('title' => ts('Pledge End Date'), - 'type' => CRM_Utils_Type::T_DATE, - ), - 'status_id' => - array('title' => ts('Pledge Status'), + 'grouping' => 'contact-fields', + 'group_bys' => array( + 'id' => array('title' => ts('Contact ID')), + 'sort_name' => array( + 'title' => ts('Contact Name'), + ), ), ), - 'filters' => - array( - 'pledge_create_date' => - array( - 'title' => 'Pledge Made Date', - 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'pledge_amount' => - array('title' => ts('Pledged Amount'), - 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'currency' => - array('title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'sid' => - array( - 'name' => 'status_id', - 'title' => ts('Pledge Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('contribution_status'), + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'no_repeat' => TRUE, + 'title' => ts('email'), + ), ), + 'grouping' => 'contact-fields', ), - 'group_bys' => - array( - 'pledge_create_date' => - array( - 'frequency' => TRUE, - 'default' => TRUE, - 'chart' => TRUE, + 'civicrm_pledge' => array( + 'dao' => 'CRM_Pledge_DAO_Pledge', + 'fields' => array( + 'id' => array( + 'no_display' => TRUE, + 'required' => FALSE, + ), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, + ), + 'amount' => array( + 'title' => ts('Pledge Amount'), + 'required' => TRUE, + 'type' => CRM_Utils_Type::T_MONEY, + 'statistics' => array( + 'sum' => ts('Aggregate Amount Pledged'), + 'count' => ts('Pledges'), + 'avg' => ts('Average'), + ), + ), + 'frequency_unit' => array( + 'title' => ts('Frequency Unit'), + ), + 'installments' => array( + 'title' => ts('Installments'), + ), + 'pledge_create_date' => array( + 'title' => ts('Pledge Made Date'), + ), + 'start_date' => array( + 'title' => ts('Pledge Start Date'), + 'type' => CRM_Utils_Type::T_DATE, + ), + 'end_date' => array( + 'title' => ts('Pledge End Date'), + 'type' => CRM_Utils_Type::T_DATE, + ), + 'status_id' => array( + 'title' => ts('Pledge Status'), + ), ), - 'frequency_unit' => - array('title' => ts('Frequency Unit'), + 'filters' => array( + 'pledge_create_date' => array( + 'title' => 'Pledge Made Date', + 'operatorType' => CRM_Report_Form::OP_DATE, + ), + 'pledge_amount' => array( + 'title' => ts('Pledged Amount'), + 'operatorType' => CRM_Report_Form::OP_INT, + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'sid' => array( + 'name' => 'status_id', + 'title' => ts('Pledge Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('contribution_status'), + ), ), - 'status_id' => - array('title' => ts('Pledge Status'), + 'group_bys' => array( + 'pledge_create_date' => array( + 'frequency' => TRUE, + 'default' => TRUE, + 'chart' => TRUE, + ), + 'frequency_unit' => array( + 'title' => ts('Frequency Unit'), + ), + 'status_id' => array( + 'title' => ts('Pledge Status'), + ), ), ), - ), - 'civicrm_pledge_payment' => - array( - 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => - array( - 'total_paid' => - array( + 'civicrm_pledge_payment' => array( + 'dao' => 'CRM_Pledge_DAO_PledgePayment', + 'fields' => array( + 'total_paid' => array( 'title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_STRING, 'dbAlias' => 'sum(pledge_payment_civireport.actual_amount)', ), + ), ), - ), - ) + $this->addAddressFields(); + ) + $this->addAddressFields(); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -232,7 +212,7 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { {$this->_aliases['civicrm_email']}.is_primary = 1\n"; } - if (!empty($this->_params['fields']['total_paid'])){ + if (!empty($this->_params['fields']['total_paid'])) { $this->_from .= " LEFT JOIN civicrm_pledge_payment {$this->_aliases['civicrm_pledge_payment']} ON {$this->_aliases['civicrm_pledge']}.id = {$this->_aliases['civicrm_pledge_payment']}.pledge_id @@ -256,12 +236,14 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { $this->assign('chartSupported', TRUE); } - if (!empty($table['group_bys'][$fieldName]['frequency']) && !empty($this->_params['group_bys_freq'][$fieldName])) { + if (!empty($table['group_bys'][$fieldName]['frequency']) && + !empty($this->_params['group_bys_freq'][$fieldName]) + ) { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') - )) { + array('year') + )) { $append = ''; } $this->_groupBy[] = "$append {$this->_params['group_bys_freq'][$fieldName]}({$field['dbAlias']})"; @@ -276,11 +258,13 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { } if (!empty($this->_statFields) && - (($append && count($this->_groupBy) <= 1) || (!$append)) && !$this->_having + (($append && count($this->_groupBy) <= 1) || (!$append)) && + !$this->_having ) { $this->_rollup = " WITH ROLLUP"; } - $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . " {$this->_rollup} "; + $this->_groupBy = "GROUP BY " . implode(', ', $this->_groupBy) . + " {$this->_rollup} "; } else { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id"; @@ -334,8 +318,8 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); @@ -387,8 +371,8 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { */ function alterDisplay(&$rows) { // custom code to alter rows - $entryFound = FALSE; - $checkList = array(); + $entryFound = FALSE; + $checkList = array(); $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Walklist/Walklist.php b/CRM/Report/Form/Walklist/Walklist.php index a88e4b7dce..d117e43071 100644 --- a/CRM/Report/Form/Walklist/Walklist.php +++ b/CRM/Report/Form/Walklist/Walklist.php @@ -45,7 +45,10 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); protected $_customGroupExtends = array( - 'Contact', 'Individual', 'Household', 'Organization' + 'Contact', + 'Individual', + 'Household', + 'Organization' ); /** @@ -56,57 +59,55 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { */ function __construct() { $this->_columns = array( - 'civicrm_contact' => - array( + 'civicrm_contact' => array( 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => - array( - 'id' => - array('title' => ts('Contact ID'), + 'fields' => array( + 'id' => array( + 'title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE, ), - 'sort_name' => - array('title' => ts('Contact Name'), + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, ), ), - 'filters' => - array( - 'sort_name' => - array('title' => ts('Contact Name'), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'operator' => 'like', ), ), 'grouping' => 'contact-fields', - 'order_bys' => - array('sort_name' => array('title' => ts('Contact Name'), + 'order_bys' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), 'required' => TRUE, - )), + ) + ), ), - 'civicrm_address' => - array( + 'civicrm_address' => array( 'dao' => 'CRM_Core_DAO_Address', - 'fields' => - array( - 'street_number' => array('title' => ts('Street Number'), + 'fields' => array( + 'street_number' => array( + 'title' => ts('Street Number'), 'type' => 1, ), 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => - array('title' => ts('State/Province'), + 'state_province_id' => array( + 'title' => ts('State/Province'), 'default' => TRUE, ), - 'country_id' => - array('title' => ts('Country'), + 'country_id' => array( + 'title' => ts('Country'), ), ), - 'filters' => - array( - 'street_number' => array('title' => ts('Street Number'), + 'filters' => array( + 'street_number' => array( + 'title' => ts('Street Number'), 'type' => 1, 'name' => 'street_number', ), @@ -115,18 +116,14 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { ), 'grouping' => 'location-fields', ), - 'civicrm_email' => - array( + 'civicrm_email' => array( 'dao' => 'CRM_Core_DAO_Email', - 'fields' => - array('email' => array('default' => TRUE)), + 'fields' => array('email' => array('default' => TRUE)), 'grouping' => 'location-fields', ), - 'civicrm_phone' => - array( + 'civicrm_phone' => array( 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => - array('phone' => NULL), + 'fields' => array('phone' => NULL), 'grouping' => 'location-fields', ), ); @@ -143,7 +140,9 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { $this->_columnHeaders = array(); foreach ($this->_columns as $tableName => $table) { foreach ($table['fields'] as $fieldName => $field) { - if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) { + if (!empty($field['required']) || + !empty($this->_params['fields'][$fieldName]) + ) { if ($tableName == 'civicrm_address') { $this->_addressField = TRUE; } @@ -192,8 +191,8 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom if ($field['type'] & CRM_Utils_Type::T_DATE) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); + $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } diff --git a/CRM/SMS/Form/Schedule.php b/CRM/SMS/Form/Schedule.php index 66fe82f1f5..d214d0e3d1 100644 --- a/CRM/SMS/Form/Schedule.php +++ b/CRM/SMS/Form/Schedule.php @@ -141,8 +141,7 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { $params['start_date_time'] )) < CRM_Utils_Date::format(date('YmdHi00'))) { return array( - 'start_date' => - ts('Start date cannot be earlier than the current time.'), + 'start_date' => ts('Start date cannot be earlier than the current time.'), ); } return TRUE; diff --git a/CRM/Upgrade/Incremental/php/FourOne.php b/CRM/Upgrade/Incremental/php/FourOne.php index 7a8e95e3da..9476aa95a3 100644 --- a/CRM/Upgrade/Incremental/php/FourOne.php +++ b/CRM/Upgrade/Incremental/php/FourOne.php @@ -58,16 +58,21 @@ class CRM_Upgrade_Incremental_php_FourOne { * * @param $postUpgradeMessage string, alterable * @param $rev string, an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs + * * @return void */ function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { if ($rev == '4.1.alpha1') { - $postUpgradeMessage .= '
' . ts('WARNING! CiviCRM 4.1 introduces an improved way of handling cron jobs. However the new method is NOT backwards compatible. Please notify your system administrator that all CiviCRM related cron jobs will cease to work, and will need to be re-configured (this includes sending CiviMail mailings, updating membership statuses, etc.). Refer to the online documentation for detailed instructions.', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC41/Managing+Scheduled+Jobs')); - $postUpgradeMessage .= '
' . ts('The CiviCRM Administration menu structure has been re-organized during this upgrade to make it easier to find things and reduce the number of keystrokes. If you have customized this portion of the navigation menu - you should take a few minutes to review the changes. You may need to reimplement or move your customizations.'); + $postUpgradeMessage .= '
' . + ts('WARNING! CiviCRM 4.1 introduces an improved way of handling cron jobs. However the new method is NOT backwards compatible. Please notify your system administrator that all CiviCRM related cron jobs will cease to work, and will need to be re-configured (this includes sending CiviMail mailings, updating membership statuses, etc.). Refer to the online documentation for detailed instructions.', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC41/Managing+Scheduled+Jobs')); + $postUpgradeMessage .= '
' . + ts('The CiviCRM Administration menu structure has been re-organized during this upgrade to make it easier to find things and reduce the number of keystrokes. If you have customized this portion of the navigation menu - you should take a few minutes to review the changes. You may need to reimplement or move your customizations.'); - $postUpgradeMessage .= '
' . ts('Yahoo recently discontinued their geocoding and mapping API service. If you previously used Yahoo, you will need to select and configure an alternate service in order to continue using geocoding/mapping tools.'); + $postUpgradeMessage .= '
' . + ts('Yahoo recently discontinued their geocoding and mapping API service. If you previously used Yahoo, you will need to select and configure an alternate service in order to continue using geocoding/mapping tools.'); - $postUpgradeMessage .= '
' . ts('We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.'); + $postUpgradeMessage .= '
' . + ts('We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.'); } } @@ -83,8 +88,14 @@ class CRM_Upgrade_Incremental_php_FourOne { if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) { $afterUpgradeMessage .= "

"; } - $afterUpgradeMessage .= '
' . ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:"); - $afterUpgradeMessage .= '
' . CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '
' . CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '
' . '
'; + $afterUpgradeMessage .= + '
' . + ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:"); + $afterUpgradeMessage .= + '
' . + CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '
' . + CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '
' . + '
'; $template->assign('afterUpgradeMessage', $afterUpgradeMessage); } } @@ -132,7 +143,6 @@ class CRM_Upgrade_Incremental_php_FourOne { ); - $userColumnNames = array( self::NAVIGATION_NAME => array( 'navigation', @@ -206,43 +216,43 @@ VALUES function createNewSettings() { $domainColumns = array( - CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => - array(array('contact_ajax_check_similar', 1), + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( + array('contact_ajax_check_similar', 1), array('activity_assignee_notification', 1), ), - CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => - array(array('tag_unconfirmed', 'Unconfirmed'), + CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array( + array('tag_unconfirmed', 'Unconfirmed'), array('petition_contacts', 'Petition Contacts'), ), - CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => - array(array('enable_cart', 0), + CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array( + array('enable_cart', 0), ), - CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => - array(array('profile_double_optin', 1), + CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array( + array('profile_double_optin', 1), array('profile_add_to_group_double_optin', 0), array('track_civimail_replies', 0), array('civimail_workflow', 0), array('civimail_server_wide_lock', 0), ), - CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => - array(array('default_renewal_contribution_page', NULL), + CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array( + array('default_renewal_contribution_page', NULL), ), - CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => - array(array('is_enabled', 0), + CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array( + array('is_enabled', 0), array('uniq_email_per_site', 0), array('domain_group_id', 0), array('event_price_set_domain_id', 0), ), - CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => - array(array('uploadDir', NULL), + CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => array( + array('uploadDir', NULL), array('imageUploadDir', NULL), array('customFileUploadDir', NULL), array('customTemplateDir', NULL), array('customPHPPathDir', NULL), array('extensionsDir', NULL), ), - CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => - array(array('userFrameworkResourceURL', NULL), + CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => array( + array('userFrameworkResourceURL', NULL), array('imageUploadURL', NULL), array('customCSSURL', NULL), ), @@ -257,7 +267,9 @@ VALUES foreach ($domainColumns as $groupName => $settings) { foreach ($settings as $setting) { - if (isset($dbSettings[$groupName][$setting[0]]) && !empty($dbSettings[$groupName][$setting[0]])) { + if (isset($dbSettings[$groupName][$setting[0]]) && + !empty($dbSettings[$groupName][$setting[0]]) + ) { $setting[1] = $dbSettings[$groupName][$setting[0]]; } @@ -311,13 +323,13 @@ AND v.is_active = 1 * @param $rev */ function upgrade_4_1_alpha2($rev) { - $dao = new CRM_Core_DAO_Setting(); + $dao = new CRM_Core_DAO_Setting(); $dao->group_name = 'Directory Preferences'; - $dao->name = 'customTemplateDir'; + $dao->name = 'customTemplateDir'; if (!($dao->find(TRUE))) { - $dao->domain_id = CRM_Core_Config::domainID(); + $dao->domain_id = CRM_Core_Config::domainID(); $dao->created_date = date('YmdHis'); - $dao->is_domain = 0; + $dao->is_domain = 0; $dao->save(); } $dao->free(); @@ -338,41 +350,34 @@ AND v.is_active = 1 } $domainCols = array( - CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( 'contact_ajax_check_similar', 'activity_assignee_notification', ), - CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array( 'tag_unconfirmed', 'petition_contacts', ), - CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array( 'enable_cart', ), - CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array( 'profile_double_optin', 'profile_add_to_group_double_optin', 'track_civimail_replies', 'civimail_workflow', 'civimail_server_wide_lock', ), - CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array( 'default_renewal_contribution_page', ), - CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array( 'is_enabled', 'uniq_email_per_site', 'domain_group_id', 'event_price_set_domain_id', ), - CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => array( 'uploadDir', 'imageUploadDir', 'customFileUploadDir', @@ -380,8 +385,7 @@ AND v.is_active = 1 'customPHPPathDir', 'extensionsDir', ), - CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => - array( + CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => array( 'userFrameworkResourceURL', 'imageUploadURL', 'customCSSURL', @@ -389,8 +393,8 @@ AND v.is_active = 1 ); $arrGroupNames = array_keys($domainCols); - $groupNames = implode("','", $arrGroupNames); - $arrNames = array(); + $groupNames = implode("','", $arrGroupNames); + $arrNames = array(); foreach ($domainCols as $groupName => $names) { $arrNames[] = implode("','", $names); } diff --git a/CRM/Upgrade/Incremental/php/FourTwo.php b/CRM/Upgrade/Incremental/php/FourTwo.php index e52ca01da2..2ca99e547e 100644 --- a/CRM/Upgrade/Incremental/php/FourTwo.php +++ b/CRM/Upgrade/Incremental/php/FourTwo.php @@ -388,15 +388,12 @@ HAVING COUNT(cpse.price_set_id) > 1 AND MIN(cpse1.id) <> cpse.id "; */ static function task_4_2_alpha1_createPriceSets(CRM_Queue_TaskContext $ctx, $rev) { $upgrade = new CRM_Upgrade_Form(); - $daoName = - array( - 'civicrm_contribution_page' => - array( + $daoName = array( + 'civicrm_contribution_page' => array( 'CRM_Contribute_BAO_ContributionPage', CRM_Core_Component::getComponentID('CiviContribute') ), - 'civicrm_event' => - array( + 'civicrm_event' => array( 'CRM_Event_BAO_Event', CRM_Core_Component::getComponentID('CiviEvent') ), diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 1b27afc40e..80076b23bf 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -104,8 +104,7 @@ class CRM_Utils_Token { if (self::$_requiredTokens == NULL) { self::$_requiredTokens = array( 'domain.address' => ts("Domain address - displays your organization's postal address."), - 'action.optOutUrl or action.unsubscribeUrl' => - array( + 'action.optOutUrl or action.unsubscribeUrl' => array( 'action.optOut' => ts("'Opt out via email' - displays an email address for recipients to opt out of receiving emails from your organization."), 'action.optOutUrl' => ts("'Opt out via web page' - creates a link for recipients to click if they want to opt out of receiving emails from your organization. Alternatively, you can include the 'Opt out via email' token."), 'action.unsubscribe' => ts("'Unsubscribe via email' - displays an email address for recipients to unsubscribe from the specific mailing list used to send this message."), diff --git a/CRM/Widget/Widget.php b/CRM/Widget/Widget.php index 364c6a0956..8fe69dc256 100644 --- a/CRM/Widget/Widget.php +++ b/CRM/Widget/Widget.php @@ -12,11 +12,11 @@ class CRM_Widget_Widget { static $_methodTable; + function initialize() { if (!self::$_methodTable) { self::$_methodTable = array( - 'getContributionPageData' => - array( + 'getContributionPageData' => array( 'description' => 'Gets all campaign related data and returns it as a std class.', 'access' => 'remote', 'arguments' => array( @@ -24,8 +24,7 @@ class CRM_Widget_Widget { 'widgetID', ), ), - 'getEmbedCode' => - array( + 'getEmbedCode' => array( 'description' => 'Gets embed code. Perhaps overkill, but we can track dropoffs in this case. by # of people reqeusting emebed code / number of unique instances.', 'access' => 'remote', 'arguments' => array( @@ -93,11 +92,11 @@ class CRM_Widget_Widget { $data->is_active = FALSE; } - $data->is_active = TRUE; - $data->title = $widget->title; - $data->logo = $widget->url_logo; + $data->is_active = TRUE; + $data->title = $widget->title; + $data->logo = $widget->url_logo; $data->button_title = $widget->button_title; - $data->button_url = CRM_Utils_System::url('civicrm/contribute/transact', + $data->button_url = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id=$contributionPageID", TRUE, NULL, FALSE, TRUE ); @@ -190,7 +189,8 @@ WHERE id = %1"; */ public function getEmbedCode($contributionPageID, $widgetID, $format = "normal") { self::registerRequest($contributionPageID, $widgetID, __FUNCTION__); - return "......................." . print_r(func_get_args(), 1); + return "......................." . + print_r(func_get_args(), 1); } } -- 2.25.1