当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_OptionGroup::getDefaultValue方法代码示例

本文整理汇总了PHP中CRM_Core_OptionGroup::getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_OptionGroup::getDefaultValue方法的具体用法?PHP CRM_Core_OptionGroup::getDefaultValue怎么用?PHP CRM_Core_OptionGroup::getDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_OptionGroup的用法示例。


在下文中一共展示了CRM_Core_OptionGroup::getDefaultValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setDefaultValues

 /**
  * Set default values for the form.
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $defaults = array();
     if (isset($this->_id)) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
         CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title)));
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'event';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Promote this event with a personal campaign page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($this->_id && ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt'))) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:32,代码来源:Event.php

示例2: setDefaultValues

 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_contribution_page');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'contribute';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Create your own fundraising page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt')) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:30,代码来源:Contribute.php

示例3: setDefaultValues

 /**
  * Set default values for the form.
  *
  * For edit/view mode the default values are retrieved from the database.
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues();
     // if we're editing...
     if (isset($this->_activityId)) {
         if (empty($defaults['activity_date_time'])) {
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
         } elseif ($this->_action & CRM_Core_Action::UPDATE) {
             $this->assign('current_activity_date_time', $defaults['activity_date_time']);
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
             list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
         }
         if ($this->_context != 'standalone') {
             $this->assign('target_contact_value', CRM_Utils_Array::value('target_contact_value', $defaults));
             $this->assign('assignee_contact_value', CRM_Utils_Array::value('assignee_contact_value', $defaults));
         }
         // Fixme: why are we getting the wrong keys from upstream?
         $defaults['target_contact_id'] = CRM_Utils_Array::value('target_contact', $defaults);
         $defaults['assignee_contact_id'] = CRM_Utils_Array::value('assignee_contact', $defaults);
         // set default tags if exists
         $defaults['tag'] = CRM_Core_BAO_EntityTag::getTag($this->_activityId, 'civicrm_activity');
     } else {
         // if it's a new activity, we need to set default values for associated contact fields
         $this->_sourceContactId = $this->_currentUserId;
         $this->_targetContactId = $this->_currentlyViewedContactId;
         $defaults['source_contact_id'] = $this->_sourceContactId;
         $defaults['target_contact_id'] = $this->_targetContactId;
         list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
     }
     if ($this->_activityTypeId) {
         $defaults['activity_type_id'] = $this->_activityTypeId;
     }
     if (!$this->_single && !empty($this->_contactIds)) {
         $defaults['target_contact_id'] = $this->_contactIds;
     }
     // CRM-15472 - 50 is around the practical limit of how many items a select2 entityRef can handle
     if (!empty($defaults['target_contact_id'])) {
         $count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id']));
         if ($count > 50) {
             $this->freeze(array('target_contact_id'));
         }
     }
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         $this->assign('delName', CRM_Utils_Array::value('subject', $defaults));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $defaults += $className::setDefaultValues($this);
     }
     if (empty($defaults['priority_id'])) {
         $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
         $defaults['priority_id'] = array_search('Normal', $priority);
     }
     if (empty($defaults['status_id'])) {
         $defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('activity_status');
     }
     return $defaults;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:65,代码来源:Activity.php

示例4: processContribution

 /**
  * Process contribution records.
  *
  * @param array $params
  *   Associated array of submitted values.
  *
  *
  * @return void
  */
 private function processContribution(&$params)
 {
     $dates = array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date');
     // get the price set associated with offline contribution record.
     $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
     $this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
     $priceFieldID = CRM_Price_BAO_PriceSet::getOnlyPriceFieldID($this->_priceSet);
     $priceFieldValueID = CRM_Price_BAO_PriceSet::getOnlyPriceFieldValueID($this->_priceSet);
     if (isset($params['field'])) {
         foreach ($params['field'] as $key => $value) {
             // if contact is not selected we should skip the row
             if (empty($params['primary_contact_id'][$key])) {
                 continue;
             }
             $value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']);
             // update contact information
             $this->updateContactInfo($value);
             //build soft credit params
             if (!empty($params['soft_credit_contact_id'][$key]) && !empty($params['soft_credit_amount'][$key])) {
                 $value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_id'][$key];
                 $value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
                 //CRM-15350: if soft-credit-type profile field is disabled or removed then
                 //we choose configured SCT default value
                 if (!empty($params['soft_credit_type'][$key])) {
                     $value['soft_credit'][$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
                 } else {
                     $value['soft_credit'][$key]['soft_credit_type_id'] = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
                 }
             }
             $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value, NULL, 'Contribution');
             foreach ($dates as $val) {
                 if (!empty($value[$val])) {
                     $value[$val] = CRM_Utils_Date::processDate($value[$val], $value[$val . '_time'], TRUE);
                 }
             }
             if (!empty($value['send_receipt'])) {
                 $value['receipt_date'] = date('Y-m-d His');
             }
             // these translations & date handling are required because we are calling BAO directly rather than the api
             $fieldTranslations = array('financial_type' => 'financial_type_id', 'payment_instrument' => 'payment_instrument_id', 'contribution_source' => 'source', 'contribution_note' => 'note');
             foreach ($fieldTranslations as $formField => $baoField) {
                 if (isset($value[$formField])) {
                     $value[$baoField] = $value[$formField];
                 }
                 unset($value[$formField]);
             }
             $params['actualBatchTotal'] += $value['total_amount'];
             $value['batch_id'] = $this->_batchId;
             $value['skipRecentView'] = TRUE;
             // build line item params
             $this->_priceSet['fields'][$priceFieldID]['options'][$priceFieldValueID]['amount'] = $value['total_amount'];
             $value['price_' . $priceFieldID] = 1;
             $lineItem = array();
             CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
             //unset amount level since we always use quick config price set
             unset($value['amount_level']);
             //CRM-11529 for back office transactions
             //when financial_type_id is passed in form, update the
             //line items with the financial type selected in form
             if (!empty($value['financial_type_id']) && !empty($lineItem[$priceSetId])) {
                 foreach ($lineItem[$priceSetId] as &$values) {
                     $values['financial_type_id'] = $value['financial_type_id'];
                 }
             }
             $value['line_item'] = $lineItem;
             //finally call contribution create for all the magic
             $contribution = CRM_Contribute_BAO_Contribution::create($value, CRM_Core_DAO::$_nullArray);
             $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
             if (!empty($this->_batchInfo['type_id']) && $this->_batchInfo['type_id'] == $batchTypes['Pledge Payment']) {
                 $adjustTotalAmount = FALSE;
                 if (isset($params['option_type'][$key])) {
                     if ($params['option_type'][$key] == 2) {
                         $adjustTotalAmount = TRUE;
                     }
                 }
                 $pledgeId = $params['open_pledges'][$key];
                 if (is_numeric($pledgeId)) {
                     $result = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId);
                     $pledgePaymentId = 0;
                     foreach ($result as $key => $values) {
                         if ($values['status'] != 'Completed') {
                             $pledgePaymentId = $values['id'];
                             break;
                         }
                     }
                     CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $pledgePaymentId, 'contribution_id', $contribution->id);
                     CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, array($pledgePaymentId), $contribution->contribution_status_id, NULL, $contribution->total_amount, $adjustTotalAmount);
                 }
             }
             //process premiums
             if (!empty($value['product_name'])) {
//.........这里部分代码省略.........
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Entry.php

示例5: testCreateContributionWithSoftCreditDefaults

 public function testCreateContributionWithSoftCreditDefaults()
 {
     $description = "Demonstrates creating contribution with Soft Credit defaults for amount and type.";
     $subfile = "ContributionCreateWithSoftCreditDefaults";
     $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual'));
     $params = $this->_params + array('soft_credit_to' => $contact2['id']);
     $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
     $result = $this->callAPISuccess('contribution', 'get', array('return' => 'soft_credit', 'sequential' => 1));
     $this->assertEquals($contact2['id'], $result['values'][0]['soft_credit'][1]['contact_id']);
     // Default soft credit amount = contribution.total_amount
     $this->assertEquals($this->_params['total_amount'], $result['values'][0]['soft_credit'][1]['amount']);
     $this->assertEquals(CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), $result['values'][0]['soft_credit'][1]['soft_credit_type']);
     $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
     $this->callAPISuccess('contact', 'delete', array('id' => $contact2['id']));
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:15,代码来源:ContributionTest.php

示例6: _civicrm_api3_contribution_create_legacy_support_45

/**
 * Support for schema changes made in 4.5.
 *
 * The main purpose of the API is to provide integrators a level of stability not provided by
 * the core code or schema - this means we have to provide support for api calls (where possible)
 * across schema changes.
 *
 * @param array $params
 */
function _civicrm_api3_contribution_create_legacy_support_45(&$params)
{
    //legacy soft credit handling - recommended approach is chaining
    if (!empty($params['soft_credit_to'])) {
        $params['soft_credit'][] = array('contact_id' => $params['soft_credit_to'], 'amount' => $params['total_amount'], 'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"));
    }
    if (!empty($params['honor_contact_id'])) {
        $params['soft_credit'][] = array('contact_id' => $params['honor_contact_id'], 'amount' => $params['total_amount'], 'soft_credit_type_id' => CRM_Utils_Array::value('honor_type_id', $params, CRM_Core_OptionGroup::getValue('soft_credit_type', 'in_honor_of', 'name')));
    }
}
开发者ID:scardinius,项目名称:civicrm-core,代码行数:19,代码来源:Contribution.php

示例7: civicrm_api3_mailing_submit

/**
 * Mailing submit.
 *
 * @param array $params
 *
 * @return array
 * @throws API_Exception
 */
function civicrm_api3_mailing_submit($params)
{
    civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_Mailing', array('id'));
    if (!isset($params['scheduled_date']) && !isset($updateParams['approval_date'])) {
        throw new API_Exception("Missing parameter scheduled_date and/or approval_date");
    }
    if (!is_numeric(CRM_Core_Session::getLoggedInContactID())) {
        throw new API_Exception("Failed to determine current user");
    }
    $updateParams = array();
    $updateParams['id'] = $params['id'];
    // Note: we'll pass along scheduling/approval fields, but they may get ignored
    // if we don't have permission.
    if (isset($params['scheduled_date'])) {
        $updateParams['scheduled_date'] = $params['scheduled_date'];
        $updateParams['scheduled_id'] = CRM_Core_Session::getLoggedInContactID();
    }
    if (isset($params['approval_date'])) {
        $updateParams['approval_date'] = $params['approval_date'];
        $updateParams['approver_id'] = CRM_Core_Session::getLoggedInContactID();
        $updateParams['approval_status_id'] = CRM_Utils_Array::value('approval_status_id', $updateParams, CRM_Core_OptionGroup::getDefaultValue('mail_approval_status'));
    }
    if (isset($params['approval_note'])) {
        $updateParams['approval_note'] = $params['approval_note'];
    }
    if (isset($params['_skip_evil_bao_auto_recipients_'])) {
        $updateParams['_skip_evil_bao_auto_recipients_'] = $params['_skip_evil_bao_auto_recipients_'];
    }
    $updateParams['options']['reload'] = 1;
    return civicrm_api3('Mailing', 'create', $updateParams);
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:39,代码来源:Mailing.php

示例8: buildProfile


//.........这里部分代码省略.........
         list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
         $customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
         if ($customFieldID) {
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
         }
     } elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
         $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
     } elseif ($fieldName == 'send_receipt') {
         $form->addElement('checkbox', $name, $title);
     } elseif ($fieldName == 'soft_credit') {
         $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Soft Credit To'), array('create' => TRUE));
         $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
     } elseif ($fieldName == 'product_name') {
         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, '&nbsp', 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));
开发者ID:rollox,项目名称:civicrm-core,代码行数:67,代码来源:UFGroup.php

示例9: buildQuickForm

 /**
  * Function used to build form element for soft credit block.
  *
  * @param CRM_Core_Form $form
  *
  * @return void
  */
 public static function buildQuickForm(&$form)
 {
     if (!empty($form->_honor_block_is_active)) {
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = 'soft_credit';
         $ufJoinDAO->entity_id = $form->_id;
         if ($ufJoinDAO->find(TRUE)) {
             $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
             if ($jsonData) {
                 foreach (array('honor_block_title', 'honor_block_text') as $name) {
                     $form->assign($name, $jsonData[$name]);
                 }
                 $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
                 // radio button for Honor Type
                 foreach ($jsonData['soft_credit_types'] as $value) {
                     $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
                 }
                 $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
             }
         }
         return $form;
     }
     // by default generate 10 blocks
     $item_count = 11;
     $showSoftCreditRow = 2;
     if ($form->getAction() & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
     } elseif (!empty($form->_pledgeID)) {
         //Check and select most recent completed contrubtion and use it to retrieve
         //soft-credit information to use as default for current pledge payment, CRM-13981
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
         foreach ($pledgePayments as $id => $record) {
             if ($record['contribution_id']) {
                 $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
                 if ($record['status'] == 'Completed' && count($softCredits) > 0) {
                     $form->_softCreditInfo = $softCredits;
                 }
             }
         }
     }
     if (property_exists($form, "_softCreditInfo")) {
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
         $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         $form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $form->assign('siteHasPCPs', 1);
         // Fixme: Not a true entityRef field. Relies on PCP.js.tpl
         $form->add('text', 'pcp_made_through_id', ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -')));
         // stores the label
         $form->add('hidden', 'pcp_made_through');
         $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
         $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
         $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
     }
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:77,代码来源:SoftCredit.php

示例10: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = $this->_values;
     // if we're editing...
     if (isset($this->_activityId)) {
         if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
             $target_contact_value = explode(';', trim($defaults['target_contact_value']));
             $target_contact = array_combine(array_unique($defaults['target_contact']), $target_contact_value);
             if ($this->_action & CRM_Core_Action::VIEW) {
                 $this->assign('target_contact', $target_contact);
             } else {
                 //this assigned variable is used by newcontact creation widget to set defaults
                 $this->assign('prePopulateData', $this->formatContactValues($target_contact));
             }
         }
         if (!CRM_Utils_Array::crmIsEmptyArray($defaults['assignee_contact'])) {
             $assignee_contact_value = explode(';', trim($defaults['assignee_contact_value']));
             $assignee_contact = array_combine($defaults['assignee_contact'], $assignee_contact_value);
             if ($this->_action & CRM_Core_Action::VIEW) {
                 $this->assign('assignee_contact', $assignee_contact);
             } else {
                 $this->assign('assignee_contact', $this->formatContactValues($assignee_contact));
             }
         }
         if (empty($defaults['activity_date_time'])) {
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
         } elseif ($this->_action & CRM_Core_Action::UPDATE) {
             $this->assign('current_activity_date_time', $defaults['activity_date_time']);
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
         }
         //set the assignee contact count to template
         if (!empty($defaults['assignee_contact'])) {
             $this->assign('assigneeContactCount', count($defaults['assignee_contact']));
         } else {
             $this->assign('assigneeContactCount', 1);
         }
         //set the target contact count to template
         if (!empty($defaults['target_contact'])) {
             $this->assign('targetContactCount', count($defaults['target_contact']));
         } else {
             $this->assign('targetContactCount', 1);
         }
         if ($this->_context != 'standalone') {
             $this->assign('target_contact_value', CRM_Utils_Array::value('target_contact_value', $defaults));
             $this->assign('assignee_contact_value', CRM_Utils_Array::value('assignee_contact_value', $defaults));
         }
         // set default tags if exists
         $defaults['tag'] = CRM_Core_BAO_EntityTag::getTag($this->_activityId, 'civicrm_activity');
     } else {
         // if it's a new activity, we need to set default values for associated contact fields
         // since those are jQuery fields, unfortunately we cannot use defaults directly
         $this->_sourceContactId = $this->_currentUserId;
         $this->_targetContactId = $this->_currentlyViewedContactId;
         $target_contact = array();
         $defaults['source_contact_id'] = $this->_sourceContactId;
         if ($this->_context != 'standalone' && isset($this->_targetContactId)) {
             $target_contact[$this->_targetContactId] = self::_getDisplayNameById($this->_targetContactId);
         }
         //this assigned variable is used by newcontact creation widget to set defaults
         $this->assign('prePopulateData', $this->formatContactValues($target_contact));
         list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
     }
     if ($this->_activityTypeId) {
         $defaults['activity_type_id'] = $this->_activityTypeId;
     }
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         $this->assign('delName', CRM_Utils_Array::value('subject', $defaults));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $defaults += $className::setDefaultValues($this);
     }
     if (empty($defaults['priority_id'])) {
         $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
         $defaults['priority_id'] = array_search('Normal', $priority);
     }
     if (empty($defaults['status_id'])) {
         $defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('activity_status');
     }
     return $defaults;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:92,代码来源:Activity.php

示例11: buildQuickForm

 /**
  * Function used to build form element for soft credit block
  *
  * @param object   $form form object
  * @access public
  *
  * @return void
  */
 static function buildQuickForm(&$form)
 {
     if ($form->_mode == 'live' && !empty($form->_values['honor_block_is_active'])) {
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = 'soft_credit';
         $ufJoinDAO->entity_id = $form->_id;
         if ($ufJoinDAO->find(TRUE)) {
             $jsonData = json_decode($ufJoinDAO->module_data);
             if ($jsonData) {
                 $form->assign('honor_block_title', $jsonData->soft_credit->honor_block_title);
                 $form->assign('honor_block_text', $jsonData->soft_credit->honor_block_text);
                 $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
                 $extraOption = array('onclick' => "enableHonorType();");
                 // radio button for Honor Type
                 foreach ($jsonData->soft_credit->soft_credit_types as $value) {
                     $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value, $extraOption);
                 }
                 $form->addGroup($honorTypes, 'soft_credit_type_id', NULL);
             }
         }
         return $form;
     }
     $prefix = 'soft_credit_';
     // by default generate 5 blocks
     $item_count = 6;
     $showSoftCreditRow = 2;
     $showCreateNew = TRUE;
     if ($form->_action & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
     } elseif ($form->_pledgeID) {
         //Check and select most recent completed contrubtion and use it to retrieve
         //soft-credit information to use as default for current pledge payment, CRM-13981
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
         foreach ($pledgePayments as $id => $record) {
             if ($record['contribution_id']) {
                 $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
                 if ($record['status'] == 'Completed' && count($softCredits) > 0) {
                     $form->_softCreditInfo = $softCredits;
                 }
             }
         }
     }
     if (property_exists($form, "_softCreditInfo")) {
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
             $showCreateNew = FALSE;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, $prefix);
         $form->addMoney("{$prefix}amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         $form->add('select', "{$prefix}type[{$rowNumber}]", ts('Soft Credit Type'), array('' => ts('- select -')) + CRM_Core_OptionGroup::values("{$prefix}type", FALSE));
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "{$prefix}id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     // CRM-7368 allow user to set or edit PCP link for contributions
     $siteHasPCPs = CRM_Contribute_PseudoConstant::pcPage();
     if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) {
         $form->assign('siteHasPCPs', 1);
         $pcpDataUrl = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1', FALSE, NULL, FALSE);
         $form->assign('pcpDataUrl', $pcpDataUrl);
         $form->addElement('text', 'pcp_made_through', ts('Credit to a Personal Campaign Page'));
         $form->addElement('hidden', 'pcp_made_through_id', '', array('id' => 'pcp_made_through_id'));
         $form->addElement('checkbox', 'pcp_display_in_roll', ts('Display in Honor Roll?'), NULL);
         $form->addElement('text', 'pcp_roll_nickname', ts('Name (for Honor Roll)'));
         $form->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)'));
     }
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->assign('showCreateNew', $showCreateNew);
     $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("{$prefix}type"), array('id' => 'sct_default_id'));
     // Tell tpl to hide soft credit field if contribution is linked directly to a PCP Page
     if (!empty($form->_values['pcp_made_through_id'])) {
         $form->assign('pcpLinked', 1);
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:86,代码来源:SoftCredit.php

示例12: setDefaultValues

 /**
  * This function sets the default values for the form. For add/edit mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     $defaults = array();
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $defaults['template_id'] = $params['id'] = CRM_Utils_Request::retrieve('template_id', 'Integer', $this);
     }
     if (!empty($params['id'])) {
         CRM_HRRecruitment_BAO_HRVacancy::retrieve($params, $defaults);
         //format vacancy start/end date
         if (!empty($defaults['start_date'])) {
             list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['start_date'], 'activityDateTime');
         }
         if (!empty($defaults['end_date'])) {
             list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime');
         }
         //show that only number of permission row(s) which have defaults if any
         if (!empty($defaults['permission']) && count($defaults['permission'])) {
             $this->assign('showPermissionRow', count($defaults['permission']));
         }
         return $defaults;
     }
     foreach (array('application_profile', 'evaluation_profile') as $profileName) {
         if ($ufGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileName, 'id', 'name')) {
             $defaults[$profileName] = $ufGroupID;
         }
     }
     $defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('vacancy_status');
     return $defaults;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:39,代码来源:HRVacancy.php

示例13: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = $this->_values;
     // if we're editing...
     if (isset($this->_activityId)) {
         if (empty($defaults['activity_date_time'])) {
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
         } elseif ($this->_action & CRM_Core_Action::UPDATE) {
             $this->assign('current_activity_date_time', $defaults['activity_date_time']);
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
         }
         if ($this->_context != 'standalone') {
             $this->assign('target_contact_value', CRM_Utils_Array::value('target_contact_value', $defaults));
             $this->assign('assignee_contact_value', CRM_Utils_Array::value('assignee_contact_value', $defaults));
         }
         // Fixme: why are we getting the wrong keys from upstream?
         $defaults['target_contact_id'] = CRM_Utils_Array::value('target_contact', $defaults);
         $defaults['assignee_contact_id'] = CRM_Utils_Array::value('assignee_contact', $defaults);
         // set default tags if exists
         $defaults['tag'] = CRM_Core_BAO_EntityTag::getTag($this->_activityId, 'civicrm_activity');
     } else {
         // if it's a new activity, we need to set default values for associated contact fields
         $this->_sourceContactId = $this->_currentUserId;
         $this->_targetContactId = $this->_currentlyViewedContactId;
         $defaults['source_contact_id'] = $this->_sourceContactId;
         $defaults['target_contact_id'] = $this->_targetContactId;
         list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
     }
     if ($this->_activityTypeId) {
         $defaults['activity_type_id'] = $this->_activityTypeId;
     }
     if (!$this->_single && !empty($this->_contactIds)) {
         $defaults['target_contact_id'] = $this->_contactIds;
     }
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
         $this->assign('delName', CRM_Utils_Array::value('subject', $defaults));
     }
     if ($this->_activityTypeFile) {
         $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}";
         $defaults += $className::setDefaultValues($this);
     }
     if (empty($defaults['priority_id'])) {
         $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
         $defaults['priority_id'] = array_search('Normal', $priority);
     }
     if (empty($defaults['status_id'])) {
         $defaults['status_id'] = CRM_Core_OptionGroup::getDefaultValue('activity_status');
     }
     return $defaults;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:61,代码来源:Activity.php

示例14: buildQuickForm

 /**
  * Function used to build form element for soft credit block.
  *
  * @param CRM_Core_Form $form
  *
  * @return \CRM_Core_Form
  */
 public static function buildQuickForm(&$form)
 {
     if (!empty($form->_honor_block_is_active)) {
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = 'soft_credit';
         $ufJoinDAO->entity_id = $form->_id;
         if ($ufJoinDAO->find(TRUE)) {
             $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit');
             if ($jsonData) {
                 foreach (array('honor_block_title', 'honor_block_text') as $name) {
                     $form->assign($name, $jsonData[$name]);
                 }
                 $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
                 // radio button for Honor Type
                 foreach ($jsonData['soft_credit_types'] as $value) {
                     $honorTypes[$value] = $form->createElement('radio', NULL, NULL, $softCreditTypes[$value], $value);
                 }
                 $form->addGroup($honorTypes, 'soft_credit_type_id', NULL)->setAttribute('allowClear', TRUE);
             }
         }
         return $form;
     }
     // by default generate 10 blocks
     $item_count = 11;
     $showSoftCreditRow = 2;
     if ($form->getAction() & CRM_Core_Action::UPDATE) {
         $form->_softCreditInfo = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($form->_id, TRUE);
     } elseif (!empty($form->_pledgeID)) {
         //Check and select most recent completed contrubtion and use it to retrieve
         //soft-credit information to use as default for current pledge payment, CRM-13981
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($form->_pledgeID);
         foreach ($pledgePayments as $id => $record) {
             if ($record['contribution_id']) {
                 $softCredits = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($record['contribution_id'], TRUE);
                 if ($record['status'] == 'Completed' && count($softCredits) > 0) {
                     $form->_softCreditInfo = $softCredits;
                 }
             }
         }
     }
     if (property_exists($form, "_softCreditInfo")) {
         if (!empty($form->_softCreditInfo['soft_credit'])) {
             $showSoftCreditRow = count($form->_softCreditInfo['soft_credit']);
             $showSoftCreditRow++;
         }
     }
     for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) {
         $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE));
         $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
         $form->addSelect("soft_credit_type[{$rowNumber}]", array('entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type')));
         if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) {
             $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']);
         }
     }
     self::addPCPFields($form);
     $form->assign('showSoftCreditRow', $showSoftCreditRow);
     $form->assign('rowCount', $item_count);
     $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), array('id' => 'sct_default_id'));
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:66,代码来源:SoftCredit.php


注:本文中的CRM_Core_OptionGroup::getDefaultValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。