本文整理汇总了PHP中CRM_Campaign_BAO_Campaign::getCampaigns方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Campaign::getCampaigns方法的具体用法?PHP CRM_Campaign_BAO_Campaign::getCampaigns怎么用?PHP CRM_Campaign_BAO_Campaign::getCampaigns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Campaign
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Campaign::getCampaigns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm()
{
if ($this->_search) {
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey');
$this->add('text', 'petition_title', ts('Title'), $attributes['title']);
//campaigns
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$this->add('select', 'petition_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
$this->set('petitionCampaigns', $campaigns);
$this->assign('petitionCampaigns', json_encode($campaigns));
//build the array of all search params.
$this->_searchParams = array();
foreach ($this->_elements as $element) {
$name = $element->_attributes['name'];
$label = $element->_label;
if ($name == 'qfKey') {
continue;
}
$this->_searchParams[$name] = $label ? $label : $name;
}
$this->set('searchParams', $this->_searchParams);
$this->assign('searchParams', json_encode($this->_searchParams));
}
示例2: __construct
/**
*
*/
function __construct()
{
// 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', '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)), 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC')), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE)), 'grouping' => 'contact-fields'), '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), '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")), '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), 'receipt_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'campaign_id' => array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Campaign_BAO_Campaign::getCampaigns(), '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), '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'))), '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_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'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE);
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
// Don't show Batch display column and filter unless batches are being used
$this->_allBatches = CRM_Batch_BAO_Batch::getBatches();
if (!empty($this->_allBatches)) {
$this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
$this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name'));
$this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches);
$this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
$this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE);
}
// 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'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
$this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
}
$this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
}
示例3: buildQuickForm
function buildQuickForm()
{
$action = CRM_Utils_Array::value('action', $_REQUEST, '');
if (empty($action)) {
$action = CRM_Utils_Array::value('action', $_POST, '');
}
$id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
if (empty($id)) {
$id = CRM_Utils_Array::value('id', $_POST, '');
}
if ($action == 'update') {
CRM_Utils_System::setTitle('Edit Dotmailer Mapping');
$dmMappingDetails = CRM_Dotmailer_Utils::getDotmailerMappingDetails($id);
$defaults = $dmMappingDetails[$id];
$this->setDefaults($defaults);
} elseif ($action == 'add') {
CRM_Utils_System::setTitle('Add Dotmailer Mapping');
} elseif ($action == 'delete') {
$this->assign('id', $id);
$dmMappingDetails = CRM_Dotmailer_Utils::getDotmailerMappingDetails($id);
$this->assign('activity_type_label', $dmMappingDetails[$id]['activity_type_label']);
$this->assign('campaign_label', $dmMappingDetails[$id]['campaign_label']);
CRM_Utils_System::setTitle('Delete Dotmailer mapping');
} elseif ($action == 'force_delete' & !empty($id)) {
$sql = "DELETE FROM " . DOTMAILER_SETTINGS_TABLE_NAME . " WHERE id = {$id}";
CRM_Core_DAO::executeQuery($sql);
$session = CRM_Core_Session::singleton();
$message = ts('Dotmailer mapping deleted');
CRM_Core_Session::setStatus($message, 'Dotmailer mapping', 'success');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dotmailer/settings', 'reset=1'));
CRM_Utils_System::civiExit();
}
// Activity types
$activityTypes = CRM_Dotmailer_Utils::getActivityTypes();
$this->add('select', 'activity_type_id', ts('CiviCRM Activity Type'), array('' => '- select -') + $activityTypes, TRUE);
// Active campaigns
$allActiveCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, TRUE, FALSE);
$this->add('select', 'campaign_id', ts('CiviCRM Campaign'), array('' => '- select -') + $allActiveCampaigns, FALSE);
// Get list of Dotmailer Address Books
$dmAddressBooks = civicrm_api('Dotmailer', 'getaddressbooks', array('version' => 3));
$this->add('select', 'dotmailer_address_book_id', ts('Dotmailer Address Book'), array('' => '- select -') + $dmAddressBooks['values'], TRUE);
// Get list of Campaigns
$dmCampaigns = civicrm_api('Dotmailer', 'getcampaigns', array('version' => 3));
$this->add('select', 'dotmailer_campaign_id', ts('Dotmailer Campaign'), array('' => '- select -') + $dmCampaigns['values'], FALSE);
$this->addElement('hidden', 'action', $action);
$this->addElement('hidden', 'id', $id);
$this->addFormRule(array('CRM_Dotmailer_Form_DmMapping', 'formRule'));
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE)));
// export form elements
$this->assign('elementNames', $this->getRenderableElementNames());
parent::buildQuickForm();
}
示例4: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
//get the activity values
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//check for required permissions, CRM-6264
if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
$session = CRM_Core_Session::singleton();
if (!in_array($context, array('home', 'dashlet', 'dashletFullscreen'))) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
} else {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
}
$session->pushUserContext($url);
$defaults = array();
$params = array('id' => $activityId);
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
//set activity type name and description to template
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
$this->assign('activityTypeName', $activityTypeName);
$this->assign('activityTypeDescription', $activityTypeDescription);
if (!empty($defaults['mailingId'])) {
$this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
$mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
$this->assign('mailingReport', $mailingReport);
$full_open_report = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
$this->assign('openreport', $full_open_report);
$click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
$this->assign('clickreport', $click_thru_report);
}
foreach ($defaults as $key => $value) {
if (substr($key, -3) != '_id') {
$values[$key] = $value;
}
}
//get the campaign
if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
$values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
$this->assign('values', $values);
}
示例5: buildProfile
//.........这里部分代码省略.........
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type"));
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
$SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
$form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (!empty($field['is_multiple'])) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, CRM_Core_PseudoConstant::worldRegion(), $required, $selectAttributes);
} elseif ($fieldName == 'signature_html') {
$form->add('wysiwyg', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"');
}
} elseif ($fieldName == 'activity_details') {
$form->add('wysiwyg', $fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $name, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
} else {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('advcheckbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
static $hiddenSubtype = FALSE;
if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
// In registration mode params are submitted via POST and we don't have any clue
// about profile-id or the profile-type (which could be a subtype)
// To generalize the behavior and simplify the process,
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
if ($usedFor) {
$form->addElement('hidden', $usedFor . '[contact_sub_type]', $field['field_type']);
} else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
}
$hiddenSubtype = TRUE;
}
if ($view && $mode != CRM_Profile_Form::MODE_SEARCH || $isShared) {
$form->freeze($name);
}
//add the rules
if (in_array($fieldName, array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
}
}
}
示例6: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
$cancelledStatus = TRUE;
$status = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
if (CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Cancelled', $status)) {
$cancelledStatus = FALSE;
}
$this->assign('cancelledStatus', $cancelledStatus);
if (!empty($values['contribution_page_id'])) {
$contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
$values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
}
// get recieved into i.e to_financial_account_id from last trxn
$financialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC');
$values['to_financial_account'] = '';
if (!empty($financialTrxnId['financialTrxnId'])) {
$values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
if ($values['to_financial_account_id']) {
$values['to_financial_account'] = CRM_Contribute_PseudoConstant::financialAccount($values['to_financial_account_id']);
}
$values['payment_processor_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'payment_processor_id');
if ($values['payment_processor_id']) {
$values['payment_processor_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
}
}
if (!empty($values['contribution_recur_id'])) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values['recur_installments'] = $dao->installments;
$values['recur_frequency_unit'] = $dao->frequency_unit;
$values['recur_frequency_interval'] = $dao->frequency_interval;
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, CRM_Utils_Array::value('financial_type_id', $values));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
}
if ($premiumId) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->find(TRUE);
$this->assign('premium', $productDAO->name);
$this->assign('option', $dao->product_option);
$this->assign('fulfilled', $dao->fulfilled_date);
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote(CRM_Utils_Array::value('id', $values), 'civicrm_contribution');
$values['note'] = array_values($noteValue);
// show billing address location details, if exists
if (!empty($values['address_id'])) {
$addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
$addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
$addressDetails = array_values($addressDetails);
$values['billing_address'] = $addressDetails[0]['display'];
}
//assign soft credit record if exists.
$SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
if (!empty($SCRecords['soft_credit'])) {
$this->assign('softContributions', $SCRecords['soft_credit']);
unset($SCRecords['soft_credit']);
}
//assign pcp record if exists
foreach ($SCRecords as $name => $value) {
$this->assign($name, $value);
}
$lineItems = array();
if ($id) {
$lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
if (!empty($lineItem)) {
$lineItems[] = $lineItem;
}
}
$this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
$values['totalAmount'] = $values['total_amount'];
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
//.........这里部分代码省略.........
示例7: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
示例8: componentSearchClause
/**
* Build the campaign clause for component serach.
*
*/
public static function componentSearchClause(&$params, &$query)
{
$op = CRM_Utils_Array::value('op', $params, '=');
$campaign = CRM_Utils_Array::value('campaign', $params);
$tableName = CRM_Utils_Array::value('tableName', $params);
$grouping = CRM_Utils_Array::value('grouping', $params);
if (CRM_Utils_System::isNull($campaign) || empty($tableName)) {
return;
}
// fixme - what is the purpose of this code? $campaign should be
// an integer, not an array
if (is_array($campaign)) {
foreach (array('current_campaign', 'past_campaign') as $ignore) {
$index = array_search($ignore, $campaign);
if ($index !== FALSE) {
unset($campaign[$index]);
}
}
}
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$campaignIds = $campaignTitles = array();
if (is_array($campaign)) {
foreach ($campaign as $campId) {
$campaignIds[$campId] = $campId;
$campaignTitles[$campId] = $allCampaigns[$campId];
}
} else {
$campaignIds = $campaign;
if (array_key_exists($campaignIds, $allCampaigns)) {
$campaignTitles[$campaignIds] = $allCampaigns[$campaignIds];
}
}
$query->_qill[$grouping][] = ts('Campaigns %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $campaignTitles);
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("{$tableName}.campaign_id", $op, $campaignIds, 'Integer');
$query->_tables[$tableName] = $query->_whereTables[$tableName] = 1;
}
示例9: displayProfile
//.........这里部分代码省略.........
$compref[] = $communicationFields[$k];
}
}
}
$values[$index] = implode(',', $compref);
} elseif ($name == 'contact_sub_type') {
$values[$index] = implode(', ', $params[$name]);
} elseif ($name == 'group') {
$groups = CRM_Contact_BAO_GroupContact::getGroupList();
$title = array();
foreach ($params[$name] as $gId => $dontCare) {
if ($dontCare) {
$title[] = $groups[$gId];
}
}
$values[$index] = implode(', ', $title);
} elseif ($name == 'tag') {
$entityTags = $params[$name];
$allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
if (is_array($entityTags)) {
foreach ($entityTags as $tagId => $dontCare) {
$title[] = $allTags[$tagId];
}
}
$values[$index] = implode(', ', $title);
} elseif ('participant_role_id' == $name or 'participant_role' == $name) {
$roles = CRM_Event_PseudoConstant::participantRole();
$values[$index] = $roles[$params[$name]];
} elseif ('participant_status_id' == $name or 'participant_status' == $name) {
$status = CRM_Event_PseudoConstant::participantStatus();
$values[$index] = $status[$params[$name]];
} elseif (substr($name, -11) == 'campaign_id') {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($params[$name]);
$values[$index] = CRM_Utils_Array::value($params[$name], $campaigns);
} elseif (strpos($name, '-') !== FALSE) {
list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2);
$detailName = str_replace(' ', '_', $name);
if (in_array($fieldName, array('state_province', 'country', 'county'))) {
$values[$index] = $params[$detailName];
$idx = $detailName . '_id';
$values[$index] = $params[$idx];
} elseif ($fieldName == 'im') {
$providerName = NULL;
if ($providerId = $detailName . '-provider_id') {
$providerName = CRM_Utils_Array::value($params[$providerId], $imProviders);
}
if ($providerName) {
$values[$index] = $params[$detailName] . " (" . $providerName . ")";
} else {
$values[$index] = $params[$detailName];
}
} elseif ($fieldName == 'phone') {
$phoneExtField = str_replace('phone', 'phone_ext', $detailName);
if (isset($params[$phoneExtField])) {
$values[$index] = $params[$detailName] . " (" . $params[$phoneExtField] . ")";
} else {
$values[$index] = $params[$detailName];
}
} else {
$values[$index] = $params[$detailName];
}
} else {
if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
if ($params[$name]) {
$values[$index] = '[ x ]';
示例10: MIN
/**
* Get the rows for a browse operation.
*
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The nmber of rows to return.
* @param string $sort
* The sql string that describes the sort order.
*
* @param null $additionalClause
* @param array $additionalParams
*
* @return array
* The rows
*/
public function &getRows($offset, $rowCount, $sort, $additionalClause = NULL, $additionalParams = NULL)
{
$mailing = self::getTableName();
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$group = CRM_Mailing_DAO_MailingGroup::getTableName();
$session = CRM_Core_Session::singleton();
$mailingACL = self::mailingACL();
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// we only care about parent jobs, since that holds all the info on
// the mailing
$query = "\n SELECT {$mailing}.id,\n {$mailing}.name,\n {$job}.status,\n {$mailing}.approval_status_id,\n MIN({$job}.scheduled_date) as scheduled_date,\n MIN({$job}.start_date) as start_date,\n MAX({$job}.end_date) as end_date,\n createdContact.sort_name as created_by,\n scheduledContact.sort_name as scheduled_by,\n {$mailing}.created_id as created_id,\n {$mailing}.scheduled_id as scheduled_id,\n {$mailing}.is_archived as archived,\n {$mailing}.created_date as created_date,\n campaign_id,\n {$mailing}.sms_provider_id as sms_provider_id\n FROM {$mailing}\n LEFT JOIN {$job} ON ( {$job}.mailing_id = {$mailing}.id AND {$job}.is_test = 0 AND {$job}.parent_id IS NULL )\n LEFT JOIN civicrm_contact createdContact ON ( civicrm_mailing.created_id = createdContact.id )\n LEFT JOIN civicrm_contact scheduledContact ON ( civicrm_mailing.scheduled_id = scheduledContact.id )\n WHERE {$mailingACL} {$additionalClause}\n GROUP BY {$mailing}.id ";
if ($sort) {
$orderBy = trim($sort->orderBy());
if (!empty($orderBy)) {
$query .= " ORDER BY {$orderBy}";
}
}
if ($rowCount) {
$offset = CRM_Utils_Type::escape($offset, 'Int');
$rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
$query .= " LIMIT {$offset}, {$rowCount} ";
}
if (!$additionalParams) {
$additionalParams = array();
}
$dao = CRM_Core_DAO::executeQuery($query, $additionalParams);
$rows = array();
while ($dao->fetch()) {
$rows[] = array('id' => $dao->id, 'name' => $dao->name, 'status' => $dao->status ? $dao->status : 'Not scheduled', 'created_date' => CRM_Utils_Date::customFormat($dao->created_date), 'scheduled' => CRM_Utils_Date::customFormat($dao->scheduled_date), 'scheduled_iso' => $dao->scheduled_date, 'start' => CRM_Utils_Date::customFormat($dao->start_date), 'end' => CRM_Utils_Date::customFormat($dao->end_date), 'created_by' => $dao->created_by, 'scheduled_by' => $dao->scheduled_by, 'created_id' => $dao->created_id, 'scheduled_id' => $dao->scheduled_id, 'archived' => $dao->archived, 'approval_status_id' => $dao->approval_status_id, 'campaign_id' => $dao->campaign_id, 'campaign' => empty($dao->campaign_id) ? NULL : $allCampaigns[$dao->campaign_id], 'sms_provider_id' => $dao->sms_provider_id);
}
return $rows;
}
示例11: browse
/**
* called when action is browse.
*/
public function browse()
{
$links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
$membership = array();
$dao = new CRM_Member_DAO_Membership();
$dao->contact_id = $this->_contactId;
$dao->is_test = 0;
//$dao->orderBy('name');
$dao->find();
//CRM--4418, check for view, edit, delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit memberships')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviMember')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// get deceased status id
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$deceasedStatusId = array_search('Deceased', $allStatus);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
//checks membership of contact itself
while ($dao->fetch()) {
$membership[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
//carry campaign.
$membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
//get the membership status and type values.
$statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
foreach (array('status', 'membership_type') as $fld) {
$membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
}
if (!empty($statusANDType[$dao->id]['is_current_member'])) {
$membership[$dao->id]['active'] = TRUE;
}
if (empty($dao->owner_membership_id)) {
// unset renew and followup link for deceased membership
$currentMask = $mask;
if ($dao->status_id == $deceasedStatusId) {
$currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
}
$isUpdateBilling = FALSE;
$paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($membership[$dao->id]['membership_id'], 'membership', 'obj');
if (!empty($paymentObject)) {
$isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
}
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported($membership[$dao->id]['membership_id']);
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('all', NULL, NULL, $isCancelSupported, $isUpdateBilling), $currentMask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'membership.tab.row', 'Membership', $dao->id);
} else {
$membership[$dao->id]['action'] = CRM_Core_Action::formLink(self::links('view'), $mask, array('id' => $dao->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'membership.tab.row', 'Membership', $dao->id);
}
//does membership have auto renew CRM-7137.
if (!empty($membership[$dao->id]['contribution_recur_id']) && !CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])) {
$membership[$dao->id]['auto_renew'] = 1;
} else {
$membership[$dao->id]['auto_renew'] = 0;
}
// if relevant, count related memberships
if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id]) && CRM_Utils_Array::value('relationship_type_id', $statusANDType[$dao->id]) && empty($dao->owner_membership_id)) {
// not an related membership
$query = "\n SELECT COUNT(m.id)\n FROM civicrm_membership m\n LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id\n LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id\n WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0";
$num_related = CRM_Core_DAO::singleValueQuery($query);
$max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]);
$membership[$dao->id]['related_count'] = $max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array(1 => $num_related, 2 => $max_related));
} else {
$membership[$dao->id]['related_count'] = ts('N/A');
}
}
//Below code gives list of all Membership Types associated
//with an Organization(CRM-2016)
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypesByOrg($this->_contactId);
foreach ($membershipTypes as $key => $value) {
$membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, array('id' => $value['id'], 'cid' => $this->_contactId), ts('more'), FALSE, 'membershipType.organization.action', 'MembershipType', $value['id']);
}
$activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
$inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
$this->assign('activeMembers', $activeMembers);
$this->assign('inActiveMembers', $inActiveMembers);
$this->assign('membershipTypes', $membershipTypes);
if ($this->_contactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
// Refresh other tabs with related data
$this->ajaxResponse['updateTabs'] = array('#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId));
if (CRM_Core_Permission::access('CiviContribute')) {
$this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
}
}
}
示例12: getPetitionSummary
/**
* @param array $params
*
* @return array
*/
public static function getPetitionSummary($params = array())
{
$config = CRM_Core_Config::singleton();
$petitionsData = array();
//get the petitions.
$petitions = CRM_Campaign_BAO_Petition::getPetitionSummary($params);
if (!empty($petitions)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$petitionType = CRM_Campaign_BAO_Survey::getSurveyActivityType('label', TRUE);
foreach ($petitions as $pid => $petition) {
$petitionsData[$pid] = $petition;
$camapignId = CRM_Utils_Array::value('campaign_id', $petition);
$petitionsData[$pid]['campaign'] = CRM_Utils_Array::value($camapignId, $campaigns);
$petitionsData[$pid]['activity_type'] = $petitionType[$petition['activity_type_id']];
$action = array_sum(array_keys(self::petitionActionLinks()));
if ($petition['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$isActive = ts('No');
if ($petitionsData[$pid]['is_active']) {
$isActive = ts('Yes');
}
$petitionsData[$pid]['isActive'] = $isActive;
$isDefault = NULL;
if ($petitionsData[$pid]['is_default']) {
$isDefault = '<img src="' . $config->resourceBase . 'i/check.gif" alt="' . ts('Default') . '" />';
}
$petitionsData[$pid]['is_default'] = $isDefault;
$petitionsData[$pid]['action'] = CRM_Core_Action::formLink(self::petitionActionLinks(), $action, array('id' => $pid), ts('more'), FALSE, 'petition.dashboard.row', 'Petition', $pid);
}
}
return $petitionsData;
}
示例13: buildQuickForm
/**
* Function to actually build the form
*
* @param null
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
$this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE);
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
// Activity Type id
$this->addSelect('activity_type_id', array(), TRUE);
// Campaign id
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values));
$this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
// script / instructions
$this->addWysiwyg('instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40));
// release frequency
$this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
$this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger');
// max reserved contacts at a time
$this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts'));
$this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger');
// total reserved per interviewer
$this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts'));
$this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger');
// is active ?
$this->add('checkbox', 'is_active', ts('Active?'));
// is default ?
$this->add('checkbox', 'is_default', ts('Default?'));
parent::buildQuickForm();
}
示例14: getContributionColumns
/**
*
* @param array
*
* @return array
*/
function getContributionColumns() {
$this->setFinancialType();
$pseudoMethod = $this->financialTypePseudoConstant;
$specs = array(
'id' => array(
'title' => ts('Contribution ID'),
'is_filters' => TRUE,
'is_order_bys' => TRUE,
'is_fields' => TRUE,
'is_group_bys' => TRUE,
),
$this->financialTypeField => array(
'title' => ts($this->financialTypeLabel . ' (Contribution)'),
'type' => CRM_Utils_Type::T_INT,
'alter_display' => 'alterFinancialType',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::$pseudoMethod(),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
'is_group_bys' => TRUE,
),
'payment_instrument_id' => array(
'title' => ts('Payment Instrument'),
'type' => CRM_Utils_Type::T_INT,
'alter_display' => 'alterPaymentType',
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_order_bys' => TRUE,
'is_group_bys' => TRUE,
),
'contribution_status_id' => array(
'title' => ts('Contribution Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
'alter_display' => 'alterContributionStatus',
'type' => CRM_Utils_Type::T_INT,
'is_fields' => TRUE,
'is_filters' => TRUE,
'is_group_bys' => TRUE,
),
'campaign_id' => array(
'title' => ts('Campaign'),
'type' => CRM_Utils_Type::T_INT,
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Campaign_BAO_Campaign::getCampaigns(),
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'source' => array(
'title' => 'Contribution Source',
'is_fields' => TRUE,
),
'trxn_id' => array('is_fields' => TRUE),
'receive_date' => array(
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'operatorType' => CRM_Report_Form::OP_DATETIME,
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'receipt_date' => array('is_fields' => TRUE),
'fee_amount' => array('is_fields' => TRUE),
'net_amount' => array('is_fields' => TRUE),
'total_amount' => array(
'title' => ts('Contribution Amount'),
'statistics' => array('sum' => ts('Total Amount')),
'type' => CRM_Utils_Type::T_MONEY,
'is_fields' => TRUE,
'is_filters' => TRUE,
),
'check_number' => array('is_fields' => TRUE),
);
return $this->buildColumns($specs, 'civicrm_contribution', 'CRM_Contribute_BAO_Contribution');
}
示例15: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
// add contribution status name
$row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'], $contributionStatuses);
if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
} elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
$row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
}
if ($row['is_test']) {
$row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
$actions = array('id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context);
$row['action'] = CRM_Core_Action::formLink(self::links($componentId, $componentAction, $qfKey, $componentContext), $mask, $actions);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
if (CRM_Utils_Array::value('amount_level', $row)) {
CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
}
$rows[] = $row;
}
return $rows;
}