/**
 * Create or update a contribution_page
 *
 * @param array $params  Associative array of property
 *                       name/value pairs to insert in new 'contribution_page'
 * @example ContributionPageCreate.php Std Create example
 *
 * @return array api result array
 * {@getfields contribution_page_create}
 * @access public
 */
function civicrm_api3_contribution_page_create($params)
{
    $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
    CRM_Contribute_PseudoConstant::flush('contributionPageAll');
    CRM_Contribute_PseudoConstant::flush('contributionPageActive');
    return $result;
}
Exemple #2
0
 /**
  */
 public function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-fields', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'no_repeat' => TRUE, 'default' => TRUE), 'display_name' => array('title' => ts('Display Name'), 'no_repeat' => TRUE), 'addressee_display' => array('title' => ts('Addressee Name'), 'no_repeat' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type' => array('title' => ts('Contact Type'), 'no_repeat' => TRUE), 'contact_sub_type' => array('title' => ts('Contact Subtype'), 'no_repeat' => TRUE)), 'filters' => array('percentage_change' => array('title' => ts('Percentage Change'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'percentage_change', 'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )')), 'group_bys' => array('id' => array('title' => ts('Contact'), 'default' => TRUE))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('title' => ts('Street Address')), 'supplemental_address_1' => array('title' => ts('Supplemental Address 1')), 'city' => array('title' => ts('City')), 'country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province')), 'postal_code' => array('title' => ts('Postal Code'))), 'group_bys' => array('country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province')))), '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')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_source' => NULL, 'total_amount1' => array('name' => 'total_amount', 'alias' => 'contribution1', 'title' => ts('Range One Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, 'required' => TRUE, 'clause' => 'contribution_civireport1.total_amount_count as contribution1_total_amount_count, contribution_civireport1.total_amount_sum as contribution1_total_amount_sum'), 'total_amount2' => array('name' => 'total_amount', 'alias' => 'contribution2', 'title' => ts('Range Two Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, 'required' => TRUE, 'clause' => 'contribution_civireport2.total_amount_count as contribution2_total_amount_count, contribution_civireport2.total_amount_sum as contribution2_total_amount_sum')), 'grouping' => 'contri-fields', '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('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('title' => ts('Range One Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'total_amount'), '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('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'))), 'group_bys' => array('contribution_source' => NULL)));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
Exemple #3
0
 /**
  * get financial accounts of required account relationship.
  * $financialAccountType array with key account relationship and value financial account type option groups
  *
  * @param $config
  */
 public static function jqFinancial($config)
 {
     if (!isset($_GET['_value']) || empty($_GET['_value'])) {
         CRM_Utils_System::civiExit();
     }
     $defaultId = NULL;
     if ($_GET['_value'] == 'select') {
         $result = CRM_Contribute_PseudoConstant::financialAccount();
     } else {
         $financialAccountType = array('5' => 5, '3' => 1, '1' => 3, '6' => 1, '7' => 4, '8' => 1, '9' => 3, '10' => 2);
         $financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType);
         $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
         if ($financialAccountType) {
             $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = {$financialAccountType}");
         }
     }
     $elements = array(array('name' => ts('- select -'), 'value' => 'select'));
     if (!empty($result)) {
         foreach ($result as $id => $name) {
             $selectedArray = array();
             if ($id == $defaultId) {
                 $selectedArray['selected'] = 'Selected';
             }
             $elements[] = array('name' => $name, 'value' => $id) + $selectedArray;
         }
     }
     CRM_Utils_JSON::output($elements);
 }
 function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Donation Receipts - Settings', array('domain' => 'de.systopia.donrec')));
     // add profile selector + data
     $this->addElement('select', 'profile', ts('Profile', array('domain' => 'de.systopia.donrec')), CRM_Donrec_Logic_Profile::getAllNames(), array('class' => 'crm-select2'));
     $this->addElement('hidden', 'selected_profile', 'Default');
     $this->addElement('hidden', 'profile_data', json_encode(CRM_Donrec_Logic_Profile::getAllData()));
     // add all profile elements
     $this->addElement('text', 'draft_text', ts('Draft text', array('domain' => 'de.systopia.donrec')));
     $this->addElement('text', 'copy_text', ts('Copy text', array('domain' => 'de.systopia.donrec')));
     $this->addElement('text', 'id_pattern', ts('Receipt ID', array('domain' => 'de.systopia.donrec')));
     $this->addElement('checkbox', 'store_original_pdf');
     // actually inserted via template
     $this->addElement('select', 'financial_types', ts('Contribution Types', array('domain' => 'de.systopia.donrec')), CRM_Contribute_PseudoConstant::financialType(), array('multiple' => "multiple", 'class' => 'crm-select2'));
     $this->addElement('select', 'template', ts('Template', array('domain' => 'de.systopia.donrec')), CRM_Donrec_Logic_Settings::getAllTemplates(), array('class' => 'crm-select2'));
     // add profile location-type-selections
     $query = "SELECT `id`, `name` FROM `civicrm_location_type`";
     $result = CRM_Core_DAO::executeQuery($query);
     $options = array(0 => ts('primary address', array('domain' => 'de.systopia.donrec')));
     while ($result->fetch()) {
         $options[$result->id] = ts($result->name, array('domain' => 'de.systopia.donrec'));
     }
     $this->addElement('select', 'legal_address', ts('Legal Address-Type:', array('domain' => 'de.systopia.donrec')), $options);
     $this->addElement('select', 'postal_address', ts('Postal Address-Type:', array('domain' => 'de.systopia.donrec')), $options);
     $this->addElement('select', 'legal_address_fallback', ts('Fallback:', array('domain' => 'de.systopia.donrec')), $options);
     $this->addElement('select', 'postal_address_fallback', ts('Fallback:', array('domain' => 'de.systopia.donrec')), $options);
     // add generic elements
     $this->addElement('text', 'pdfinfo_path', ts('External Tool: path to <code>pdfinfo</code>', array('domain' => 'de.systopia.donrec')), CRM_Donrec_Logic_Settings::get('donrec_pdfinfo_path'));
     $this->addElement('text', 'packet_size', ts('Packet size', array('domain' => 'de.systopia.donrec')), CRM_Donrec_Logic_Settings::get('donrec_packet_size'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save', array('domain' => 'de.systopia.donrec')), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel', array('domain' => 'de.systopia.donrec')))));
     // add a custom form validation rule that allows only positive integers (i > 0)
     $this->registerRule('onlypositive', 'callback', 'onlyPositiveIntegers', 'CRM_Admin_Form_Setting_DonrecSettings');
 }
Exemple #5
0
 /**
  */
 public function __construct()
 {
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
     $yearsInPast = 4;
     $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, 0);
     $count = $date['maxYear'];
     $optionYear = array('' => ts('- select -'));
     $this->_yearStatisticsFrom = $date['minYear'];
     $this->_yearStatisticsTo = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     $relationTypeOp = array();
     $relationshipTypes = CRM_Core_PseudoConstant::relationshipType();
     foreach ($relationshipTypes as $rid => $rtype) {
         if ($rtype['label_a_b'] != $rtype['label_b_a']) {
             $relationTypeOp[$rid] = "{$rtype['label_a_b']}/{$rtype['label_b_a']}";
         } else {
             $relationTypeOp[$rid] = $rtype['label_a_b'];
         }
     }
     $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), '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, 'default' => TRUE, 'required' => TRUE), '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())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), '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), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => 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)))) + 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' => ''), '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)), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE);
     $yearConter = $this->_yearStatisticsFrom;
     $yearConter++;
     while ($yearConter <= $this->_yearStatisticsTo) {
         $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);
         $yearConter++;
     }
     $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = array('title' => ts('Aggregate Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE);
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
 /**
  *
  */
 function __construct()
 {
     // UI for selecting columns to appear in the report list
     // 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();
     $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
     if ($campaignEnabled) {
         $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $this->_columns = array('civicrm_membership' => array('dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', 'fields' => array('membership_type_id' => array('title' => 'Membership Type', 'required' => TRUE)), '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('name' => 'start_date', 'title' => ts('Membership Start Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE), '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'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT), '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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'))), 'group_bys' => array('join_date' => array('title' => ts('Member Since'), 'default' => TRUE, 'frequency' => TRUE, 'chart' => TRUE, 'type' => 12), 'membership_type_id' => array('title' => 'Membership Type', 'default' => TRUE, 'chart' => TRUE))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_id' => array('no_display' => TRUE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('currency' => array('required' => TRUE, 'no_display' => TRUE), 'total_amount' => array('title' => ts('Amount Statistics'), 'required' => TRUE, 'statistics' => array('sum' => ts('Total Payments Made'), 'count' => ts('Contribution Count'), 'avg' => ts('Average')))), '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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus())), 'grouping' => 'member-fields'));
     $this->_tagFilter = TRUE;
     // If we have a campaign, build out the relevant elements
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
         $this->_columns['civicrm_membership']['fields']['campaign_id'] = array('title' => 'Campaign', 'default' => 'false');
         $this->_columns['civicrm_membership']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
         $this->_columns['civicrm_membership']['grouping']['campaign_id'] = 'contri-fields';
         $this->_columns['civicrm_membership']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
     }
     $this->_groupFilter = TRUE;
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
 function __construct()
 {
     $yearsInPast = 4;
     $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, 0);
     $count = $date['maxYear'];
     $optionYear = array('' => ts('-- select --'));
     $this->_yearStatisticsFrom = $date['minYear'];
     $this->_yearStatisticsTo = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     $relationTypeOp = array();
     $relationshipTypes = CRM_Core_PseudoConstant::relationshipType();
     foreach ($relationshipTypes as $rid => $rtype) {
         if ($rtype['label_a_b'] != $rtype['label_b_a']) {
             $relationTypeOp[$rid] = "{$rtype['label_a_b']}/{$rtype['label_b_a']}";
         } else {
             $relationTypeOp[$rid] = $rtype['label_a_b'];
         }
     }
     $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), 'id' => array('no_display' => TRUE, 'default' => TRUE, 'required' => 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_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => 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)))) + 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' => ''), 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'contribution_status_id' => array('title' => ts('Donation Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1)), 'contribution_type_id' => array('title' => ts('Contribution Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionType()), 'total_amount' => array('title' => ts('Donation Amount')), 'total_sum' => array('title' => ts('Aggregate Amount'), 'type' => CRM_Report_Form::OP_INT, 'dbAlias' => 'civicrm_contribution_total_amount_sum', 'having' => TRUE)))) + array('civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group()))));
     $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);
     $yearConter = $this->_yearStatisticsFrom;
     $yearConter++;
     while ($yearConter <= $this->_yearStatisticsTo) {
         $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);
         $yearConter++;
     }
     $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = array('title' => ts('Aggregate Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE);
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
Exemple #8
0
 /**
  * Add the financial items and financial trxn.
  *
  * @param object $lineItem
  *   Line item object.
  * @param object $contribution
  *   Contribution object.
  * @param bool $taxTrxnID
  *
  * @return void
  */
 public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId = NULL)
 {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $itemStatus = NULL;
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses) || $contribution->contribution_status_id == array_search('Pending refund', $contributionStatuses)) {
         $itemStatus = array_search('Paid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Pending', $contributionStatuses) || $contribution->contribution_status_id == array_search('In Progress', $contributionStatuses)) {
         $itemStatus = array_search('Unpaid', $financialItemStatus);
     } elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) {
         $itemStatus = array_search('Partially paid', $financialItemStatus);
     }
     $params = array('transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, 'currency' => $contribution->currency, 'entity_table' => 'civicrm_line_item', 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . ' ' . $lineItem->label, 'status_id' => $itemStatus);
     if ($taxTrxnID) {
         $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         $params['amount'] = $lineItem->tax_amount;
         $params['description'] = $taxTerm;
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
     } else {
         $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
     }
     if ($lineItem->financial_type_id) {
         $searchParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $lineItem->financial_type_id, 'account_relationship' => $accountRel);
         $result = array();
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
         $params['financial_account_id'] = CRM_Utils_Array::value('financial_account_id', $result);
     }
     if (empty($trxnId)) {
         $trxn = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution->id, 'ASC', TRUE);
         $trxnId['id'] = $trxn['financialTrxnId'];
     }
     return self::create($params, NULL, $trxnId);
 }
Exemple #9
0
 function __construct()
 {
     $yearsInPast = 10;
     $yearsInFuture = 1;
     $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture);
     $count = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     // 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);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $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), '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'))), '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)))) + $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)), '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')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group()))));
     // If we have a campaign, build out the relevant elements
     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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
     }
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
Exemple #10
0
    function __construct()
    {
        $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-fields', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'no_repeat' => true, 'default' => true), 'id' => array('no_display' => true, 'required' => true)), 'group_bys' => array('id' => array('title' => ts('Contact'), 'default' => true))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province'))), 'group_bys' => array('country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province')))), 'civicrm_contribution_type' => array('dao' => 'CRM_Contribute_DAO_ContributionType', 'fields' => array('contribution_type' => null), 'grouping' => 'contri-fields', 'group_bys' => array('contribution_type' => array('name' => 'id'))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_source' => null, 'total_amount1' => array('name' => 'total_amount', 'alias' => 'contribution1', 'title' => ts('Range One Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => true, 'required' => true, 'statistics' => array('sum' => ts('Total Amount'), 'count' => ts('Count')), 'clause' => '
contribution1_total_amount_count, contribution1_total_amount_sum'), 'total_amount2' => array('name' => 'total_amount', 'alias' => 'contribution2', 'title' => ts('Range Two Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => true, 'required' => true, 'statistics' => array('sum' => ts('Total Amount'), 'count' => ts('Count')), 'clause' => '
contribution2_total_amount_count, contribution2_total_amount_sum')), 'grouping' => 'contri-fields', 'filters' => array('receive_date1' => array('title' => ts('Date Range One'), 'default' => 'previous.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', 'alias' => 'contribution1'), 'receive_date2' => array('title' => ts('Date Range Two'), 'default' => 'this.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', 'alias' => 'contribution2'), 'total_amount1' => array('title' => ts('Range One Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'receive_date', 'dbAlias' => 'contribution1_total_amount_sum'), 'total_amount2' => array('title' => ts('Range Two Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'receive_date', 'dbAlias' => 'contribution2_total_amount_sum'), 'contribution_status_id' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1'))), 'group_bys' => array('contribution_source' => null)), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => true, 'options' => CRM_Core_PseudoConstant::group()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag()))));
        parent::__construct();
    }
Exemple #11
0
 function __construct()
 {
     // 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_membership' => array('dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', 'fields' => array('membership_type_id' => array('title' => 'Membership Type', 'required' => true)), 'filters' => array('join_date' => array('title' => 'Member Since', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE), '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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(null, null, 'label'))), 'group_bys' => array('join_date' => array('title' => ts('Member Since'), 'default' => true, 'frequency' => true, 'chart' => true, 'type' => 12), 'membership_type_id' => array('title' => 'Membership Type', 'default' => true, 'chart' => true))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_id' => array('no_display' => true))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('total_amount' => array('title' => ts('Amount Statistics'), 'required' => true, 'statistics' => array('sum' => ts('Total Payments Made'), 'count' => ts('Contribution Count'), 'avg' => ts('Average')))), 'filters' => array('contribution_status_id' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus())), 'grouping' => 'member-fields'));
     parent::__construct();
 }
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Utils/Money.php';
     $this->_first = true;
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage');
     // name
     $this->add('text', 'title', ts('Title'), $attributes['title'], true);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), CRM_Contribute_PseudoConstant::contributionType(), true);
     $this->addWysiwyg('intro_text', ts('Introductory Message'), $attributes['intro_text']);
     $this->addWysiwyg('footer_text', ts('Footer Message'), $attributes['footer_text']);
     // is on behalf of an organization ?
     $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), null, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);"));
     $options = array();
     $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Optional'), 1);
     $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Required'), 2);
     $this->addGroup($options, 'is_for_organization', ts(''));
     $this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']);
     // collect goal amount
     $this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12));
     $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
     // is this page active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
     // should the honor be enabled
     $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), null, array('onclick' => "showHonor()"));
     $this->add('text', 'honor_block_title', ts('Honoree Section Title'), $attributes['honor_block_title']);
     $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), $attributes['honor_block_text']);
     // add optional start and end dates
     $this->addDateTime('start_date', ts('Start Date'));
     $this->addDateTime('end_date', ts('End Date'));
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'));
     parent::buildQuickForm();
 }
 function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Find Contributors by Aggregate Totals');
     /**
      * Define the search form fields here
      */
     $form->add('text', 'min_amount', ts('Aggregate Total Between $'));
     $form->addRule('min_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
     $form->add('text', 'max_amount', ts('...and $'));
     $form->addRule('max_amount', ts('Please enter a valid amount (numbers and decimal point only).'), 'money');
     $form->addDate('start_date', ts('Contribution Date From'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
     $financial_types = CRM_Contribute_PseudoConstant::financialType();
     foreach ($financial_types as $financial_type_id => $financial_type) {
         $form->addElement('checkbox', "financial_type_id[{$financial_type_id}]", 'Financial Type', $financial_type);
     }
     /**
      * If you are using the sample template, this array tells the template fields to render
      * for the search form.
      */
     $form->assign('elements', array('min_amount', 'max_amount', 'start_date', 'end_date', 'financial_type_id'));
 }
 /**
  */
 public function __construct()
 {
     $this->_rollup = 'WITH ROLLUP';
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
     $yearsInPast = 10;
     $yearsInFuture = 1;
     $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture);
     $count = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     // 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);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $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), '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), '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())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'age_at_event' => array('name' => 'age_at_event', 'title' => ts('Age at Event')), '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), '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), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem'), '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))));
     $this->_columns += $this->addAddressFields();
     $this->_columns += 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)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'type' => CRM_Utils_Type::T_INT), 'financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes()), '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)) {
         $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('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, 'type' => CRM_Utils_Type::T_INT);
     }
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
Exemple #15
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $count = 0;
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
         foreach ($this->_contributionIds as $key => $id) {
             $finTypeID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $id, 'financial_type_id');
             if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($finTypeID))) {
                 unset($this->_contributionIds[$key]);
                 $count++;
             }
             // Now check for lineItems
             if ($lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($id)) {
                 foreach ($lineItems as $items) {
                     if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
                         unset($this->_contributionIds[$key]);
                         $count++;
                         break;
                     }
                 }
             }
         }
     }
     if ($count && empty($this->_contributionIds)) {
         CRM_Core_Session::setStatus(ts('1 contribution could not be deleted.', array('plural' => '%count contributions could not be deleted.', 'count' => $count)), ts('Error'), 'error');
         $this->addButtons(array(array('type' => 'back', 'name' => ts('Cancel'))));
     } elseif ($count && !empty($this->_contributionIds)) {
         CRM_Core_Session::setStatus(ts('1 contribution will not be deleted.', array('plural' => '%count contributions will not be deleted.', 'count' => $count)), ts('Warning'), 'warning');
         $this->addDefaultButtons(ts('Delete Contributions'), 'done');
     } else {
         $this->addDefaultButtons(ts('Delete Contributions'), 'done');
     }
 }
 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'))), '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), '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('Donation 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)), 'grouping' => 'email-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'phone-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::nestedGroup()))));
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
 /**
  * create all fields needed for a credit card transaction
  *
  * @return void
  * @access public
  */
 function setCreditCardFields(&$form)
 {
     CRM_Core_Payment_Form::_setPaymentFields($form);
     $form->_paymentFields['credit_card_number'] = array('htmlType' => 'text', 'name' => 'credit_card_number', 'title' => ts('Card Number'), 'cc_field' => TRUE, 'attributes' => array('size' => 20, 'maxlength' => 20, 'autocomplete' => 'off'), 'is_required' => TRUE);
     $form->_paymentFields['cvv2'] = array('htmlType' => 'text', 'name' => 'cvv2', 'title' => ts('Security Code'), 'cc_field' => TRUE, 'attributes' => array('size' => 5, 'maxlength' => 10, 'autocomplete' => 'off'), 'is_required' => CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'cvv_backoffice_required', CRM_Core_Component::getComponentID('CiviContribute'), 1));
     $form->_paymentFields['credit_card_exp_date'] = array('htmlType' => 'date', 'name' => 'credit_card_exp_date', 'title' => ts('Expiration Date'), 'cc_field' => TRUE, 'attributes' => CRM_Core_SelectValues::date('creditCard'), 'is_required' => TRUE);
     $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard();
     $form->_paymentFields['credit_card_type'] = array('htmlType' => 'select', 'name' => 'credit_card_type', 'title' => ts('Card Type'), 'cc_field' => TRUE, 'attributes' => $creditCardType, 'is_required' => TRUE);
 }
Exemple #18
0
 /** 
  * create all fields needed for a credit card transaction
  *                                                           
  * @return void 
  * @access public 
  */
 function setCreditCardFields(&$form)
 {
     CRM_Core_Payment_Form::_setPaymentFields($form);
     $form->_fields['credit_card_number'] = array('htmlType' => 'text', 'name' => 'credit_card_number', 'title' => ts('Card Number'), 'cc_field' => true, 'attributes' => array('size' => 20, 'maxlength' => 20, 'autocomplete' => 'off'), 'is_required' => true);
     $form->_fields['cvv2'] = array('htmlType' => 'text', 'name' => 'cvv2', 'title' => ts('Security Code'), 'cc_field' => true, 'attributes' => array('size' => 5, 'maxlength' => 10, 'autocomplete' => 'off'), 'is_required' => true);
     $form->_fields['credit_card_exp_date'] = array('htmlType' => 'date', 'name' => 'credit_card_exp_date', 'title' => ts('Expiration Date'), 'cc_field' => true, 'attributes' => CRM_Core_SelectValues::date('creditCard'), 'is_required' => true);
     require_once 'CRM/Contribute/PseudoConstant.php';
     $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard();
     $form->_fields['credit_card_type'] = array('htmlType' => 'select', 'name' => 'credit_card_type', 'title' => ts('Card Type'), 'cc_field' => true, 'attributes' => $creditCardType, 'is_required' => true);
 }
 function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name', array('domain' => 'org.civicrm.cdntaxreceipts')), 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'grouping' => 'tax-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name', array('domain' => 'org.civicrm.cdntaxreceipts'))))), 'civicrm_financial_type' => array('dao' => 'CRM_Financial_DAO_FinancialType', 'fields' => array('financial_type' => array('default' => TRUE)), 'grouping' => 'tax-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('receive_date' => array('default' => TRUE), 'total_amount' => array('default' => TRUE), 'contribution_source' => array('default' => TRUE), 'id' => array('title' => 'Contribution ID', 'default' => TRUE)), 'filters' => array('receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array('title' => ts('Financial Type', array('domain' => 'org.civicrm.cdntaxreceipts')), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT)), 'grouping' => 'tax-fields', 'order_bys' => array('total_amount' => NULL, 'receive_date' => array('default' => '1', 'default_weight' => '0', 'default_order' => 'DESC'))));
     if (CRM_Core_BAO_Setting::getItem(self::SETTINGS, 'enable_advanced_eligibility_report', NULL, 0) == 1) {
         $enable_options = array(1 => ts('Yes'), 0 => ts('No'));
     } elseif (CRM_Core_BAO_Setting::getItem(self::SETTINGS, 'enable_advanced_eligibility_report', NULL, 0) == 0) {
         $enable_options = array(0 => ts('No'), 1 => ts('Yes'));
     }
     $this->_options = array('use_advanced_eligibility' => array('title' => ts('Use Advanced Eligibility (Hooks - Memory Intensive)', array('domain' => 'org.civicrm.cdntaxreceipts')), 'type' => 'select', 'options' => $enable_options));
     parent::__construct();
 }
 /**
  */
 public function __construct()
 {
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_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), '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())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem'));
     $this->_columns += $this->getAddressColumns();
     $this->_columns += 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)), 'filters' => array('sort_name' => array('title' => ts('Participant Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')), '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_Financial_BAO_FinancialType::getAvailableFinancialTypes()), '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)), 'grouping' => 'email-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'phone-fields'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 public function buildQuickForm()
 {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title');
     $attributes['style'] = 'width: 90%';
     $this->add('text', 'title', ts('Find'), $attributes);
     $contribution_type = CRM_Contribute_PseudoConstant::contributionType();
     foreach ($contribution_type as $contributionId => $contributionName) {
         $this->addElement('checkbox', "contribution_type_id[{$contributionId}]", 'Contribution Type', $contributionName);
     }
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $values = $ids = array();
     $params = array('id' => $this->get('id'));
     CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
     $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
     if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
         $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
         $dao = new CRM_Core_DAO();
         $dao->query($sql);
         if ($dao->fetch()) {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
             $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
         }
         $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
         $values['honor_type'] = $honor[$values['honor_type_id']];
     }
     //handle custom data.
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     if (!empty($values['contribution_page_id'])) {
         $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
     }
     $values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType());
     if ($values['status_id']) {
         $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
     }
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')';
     // add Pledge to Recent Items
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther);
     // Check if this is default domain contact CRM-10482
     if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
         $displayName .= ' (' . ts('default organization') . ')';
     }
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
     //do check for campaigns
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     $this->assign($values);
 }
Exemple #23
0
 /**
  * Build the form object.
  *
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title');
     $attributes['style'] = 'width: 90%';
     $this->add('text', 'title', ts('Find'), $attributes);
     $financial_account = CRM_Contribute_PseudoConstant::financialType();
     foreach ($financial_account as $contributionId => $contributionName) {
         $this->addElement('checkbox', "financial_type_id[{$contributionId}]", 'Financial Type', $contributionName);
     }
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     $this->_first = true;
     // name
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title'), true);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), CRM_Contribute_PseudoConstant::contributionType());
     // intro_text and footer_text
     $this->add('textarea', 'intro_text', ts('Introductory Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'intro_text'), true);
     $this->add('textarea', 'footer_text', ts('Footer Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'footer_text'), false);
     // is this group active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
     parent::buildQuickForm();
 }
Exemple #25
0
 function __construct()
 {
     $yearsInPast = 8;
     $yearsInFuture = 2;
     $date = CRM_Core_SelectValues::date('custom', null, $yearsInPast, $yearsInFuture);
     $count = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => array('display_name' => array('title' => ts('Donor Name'), 'default' => true, 'required' => true)), '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_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone No'), 'default' => true))), '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)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'clause' => "contribution_civireport.contact_id NOT IN\n((SELECT distinct contri.contact_id FROM civicrm_contribution contri \n WHERE   YEAR(contri.receive_date) =  \$value AND contri.is_test = 0) ) AND contribution_civireport.contact_id IN ((SELECT distinct contri.contact_id FROM civicrm_contribution contri \n WHERE   YEAR(contri.receive_date) =  (\$value-1) AND contri.is_test = 0) ) "), 'contribution_status_id' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => true, 'options' => CRM_Core_PseudoConstant::group()))));
     parent::__construct();
 }
 function __construct()
 {
     $yearsInPast = 10;
     $yearsInFuture = 1;
     $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture);
     $count = $date['maxYear'];
     while ($date['minYear'] <= $count) {
         $optionYear[$date['minYear']] = $date['minYear'];
         $date['minYear']++;
     }
     $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)), '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_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone No'), 'default' => TRUE))), '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)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y')), 'contribution_type_id' => array('title' => ts('Contribution Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionType()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group()))));
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
 /**
  * Function to pre  process the form
  *
  * @access public
  *
  * @return None
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_products = CRM_Contribute_PseudoConstant::products($this->_id);
     $this->_pid = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, 0);
     if ($this->_pid) {
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->id = $this->_pid;
         $dao->find(TRUE);
         $temp = CRM_Contribute_PseudoConstant::products();
         $this->_products[$dao->product_id] = $temp[$dao->product_id];
     }
     //$this->_products = array_merge(array('' => '-- Select Product --') , $this->_products );
 }
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     require_once 'CRM/Pledge/BAO/Pledge.php';
     $values = $ids = array();
     $params = array('id' => $this->get('id'));
     CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
     $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
     if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
         $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
         $dao = new CRM_Core_DAO();
         $dao->query($sql);
         if ($dao->fetch()) {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
             $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
         }
         $honor = CRM_Core_PseudoConstant::honor();
         $values['honor_type'] = $honor[$values['honor_type_id']];
     }
     //handle custom data.
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     if (CRM_Utils_Array::value('contribution_page_id', $values)) {
         $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
     }
     $values['contribution_type'] = CRM_Utils_Array::value($values['contribution_type_id'], CRM_Contribute_PseudoConstant::contributionType());
     if ($values['status_id']) {
         $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
     }
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     require_once 'CRM/Utils/Money.php';
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['contribution_type'] . ')';
     // add Pledge to Recent Items
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], null, $recentOther);
     $this->assign($values);
 }
 function buildQuickForm()
 {
     $this->addElement('hidden', 'batch_status', true);
     $this->addElement('hidden', 'id', $_GET['id']);
     $this->add('text', 'batch_title', ts('Batch Title'), array('size' => 35, 'maxlength' => 64, 'style' => 'text-align:right'), true);
     $this->add('textarea', 'description', ts('Description'), null, false);
     $emptySelect1[''] = '- select -';
     $bankAccounts = $bankAccounts = CRM_Finance_BAO_BankAccount::getBankAccountsList($emptySelect1);
     $this->add('select', 'banking_account', ts('Bank Account'), $bankAccounts, true);
     $this->addDate('banking_date', ts('Banking Date'), true, array('formatType' => 'activityDate'));
     $this->addElement('checkbox', 'exclude_from_posting', ts('Exclude from posting'), null, null);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), true);
     $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), true);
     $this->addFormRule(array($this, 'formRule'));
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->assign('formObject', $this);
 }
 function run()
 {
     if (isset($_REQUEST['group_id'])) {
         // get some values
         $group_id = (int) $_REQUEST['group_id'];
         $financial_types = CRM_Contribute_PseudoConstant::financialType();
         // load the group
         $txgroup = civicrm_api('SepaTransactionGroup', 'getsingle', array('id' => $group_id, 'version' => 3));
         if (isset($txgroup['is_error']) && $txgroup['is_error']) {
             CRM_Core_Session::setStatus(sprintf(ts("Cannot read SEPA transaction group [%s]. Error was: '%s'"), $group_id, $txgroup['error_message']), ts("Error"), "error");
         }
         // load the group's contributions
         $sql = "\n      SELECT\n        civicrm_sdd_txgroup.reference           AS reference,\n        civicrm_contact.display_name            AS contact_display_name,\n        civicrm_contact.contact_type            AS contact_contact_type,\n        civicrm_contact.id                      AS contact_id,\n        civicrm_contribution.id                 AS contribution_id,\n        civicrm_contribution.total_amount       AS contribution_amount,\n        civicrm_contribution.financial_type_id  AS contribution_financial_type_id,\n        civicrm_campaign.title                  AS contribution_campaign\n      FROM   \n        civicrm_sdd_txgroup\n      LEFT JOIN \n        civicrm_sdd_contribution_txgroup   ON   civicrm_sdd_txgroup.id = civicrm_sdd_contribution_txgroup.txgroup_id\n      LEFT JOIN \n        civicrm_contribution               ON   civicrm_contribution.id = civicrm_sdd_contribution_txgroup.contribution_id\n      LEFT JOIN \n        civicrm_contact                    ON   civicrm_contact.id = civicrm_contribution.contact_id\n      LEFT JOIN \n        civicrm_campaign                   ON   civicrm_campaign.id = civicrm_contribution.campaign_id\n      WHERE       \n        civicrm_sdd_txgroup.id = {$group_id};";
         $total_amount = 0.0;
         $total_count = 0;
         $total_campaigns = array();
         $total_types = array();
         $total_contacts = array();
         $contact_base_link = CRM_Utils_System::url('civicrm/contact/view', '&reset=1&cid=');
         $contribution_base_link = CRM_Utils_System::url('civicrm/contact/view/contribution', '&reset=1&id=_cid_&cid=_id_&action=view');
         $contributions = array();
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $contributions[$total_count] = array('contact_display_name' => $result->contact_display_name, 'contact_type' => $result->contact_contact_type, 'contact_id' => $result->contact_id, 'contact_link' => $contact_base_link . $result->contact_id, 'contribution_link' => str_replace('_id_', $result->contact_id, str_replace('_cid_', $result->contribution_id, $contribution_base_link)), 'contribution_id' => $result->contribution_id, 'contribution_amount' => $result->contribution_amount, 'contribution_amount_str' => CRM_Utils_Money::format($result->contribution_amount, 'EUR'), 'financial_type' => $financial_types[$result->contribution_financial_type_id], 'campaign' => $result->contribution_campaign);
             $total_count += 1;
             $total_amount += $result->contribution_amount;
             $total_types[$result->contribution_financial_type_id] = 1;
             $total_contacts[$result->contact_id] = 1;
             $total_campaigns[$result->contribution_campaign] = 1;
             $reference = $result->reference;
         }
     }
     $this->assign("txgroup", $txgroup);
     $this->assign("reference", $reference);
     $this->assign("group_id", $group_id);
     $this->assign("total_count", $total_count);
     $this->assign("total_amount", $total_amount);
     $this->assign("total_amount_str", CRM_Utils_Money::format($total_amount, 'EUR'));
     $this->assign("contributions", $contributions);
     $this->assign("different_campaigns", count($total_campaigns));
     $this->assign("different_types", count($total_types));
     $this->assign("different_contacts", count($total_contacts));
     parent::run();
 }