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


PHP CRM_Core_BAO_Address::fixAllStateSelects方法代码示例

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


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

示例1: setDefaultValues

 /**
  * This function sets the default values for the form. MobileProvider that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 public function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     if ($this->_priceSetId) {
         return CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $defaults);
     }
     $defaults = parent::setDefaultValues();
     //setting default join date and receive date
     list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
     if ($this->_action == CRM_Core_Action::ADD) {
         $defaults['receive_date'] = $now;
         $defaults['receive_date_time'] = $currentTime;
     }
     if (is_numeric($this->_memType)) {
         $defaults['membership_type_id'] = array();
         $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
         $defaults['membership_type_id'][1] = $this->_memType;
     } else {
         $defaults['membership_type_id'] = $this->_memType;
     }
     $defaults['num_terms'] = 1;
     if (CRM_Utils_Array::value('id', $defaults)) {
         if ($this->_onlinePendingContributionId) {
             $defaults['record_contribution'] = $this->_onlinePendingContributionId;
         } else {
             $contributionId = CRM_Core_DAO::singleValueQuery("\n  SELECT contribution_id\n  FROM civicrm_membership_payment\n  WHERE membership_id = {$this->_id}\n  ORDER BY contribution_id\n  DESC limit 1");
             if ($contributionId) {
                 $defaults['record_contribution'] = $contributionId;
             }
         }
     }
     if (CRM_Utils_Array::value('record_contribution', $defaults) && !$this->_mode) {
         $contributionParams = array('id' => $defaults['record_contribution']);
         $contributionIds = array();
         //keep main object campaign in hand.
         $memberCampaignId = CRM_Utils_Array::value('campaign_id', $defaults);
         CRM_Contribute_BAO_Contribution::getValues($contributionParams, $defaults, $contributionIds);
         //get back original object campaign id.
         $defaults['campaign_id'] = $memberCampaignId;
         if (CRM_Utils_Array::value('receive_date', $defaults)) {
             list($defaults['receive_date']) = CRM_Utils_Date::setDateDefaults($defaults['receive_date']);
         }
         // Contribution::getValues() over-writes the membership record's source field value - so we need to restore it.
         if (CRM_Utils_Array::value('membership_source', $defaults)) {
             $defaults['source'] = $defaults['membership_source'];
         }
     }
     //CRM-13420
     if (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
         $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     // User must explicitly choose to send a receipt in both add and update mode.
     $defaults['send_receipt'] = 0;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         // in this mode by default uncheck this checkbox
         unset($defaults['record_contribution']);
     }
     if (CRM_Utils_Array::value('id', $defaults)) {
         $subscriptionCancelled = CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id);
     }
     $alreadyAutoRenew = FALSE;
     if (CRM_Utils_Array::value('contribution_recur_id', $defaults) && !$subscriptionCancelled) {
         $defaults['auto_renew'] = 1;
         $alreadyAutoRenew = TRUE;
     }
     $this->assign('alreadyAutoRenew', $alreadyAutoRenew);
     $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
     $this->assign('membership_status_id', CRM_Utils_Array::value('status_id', $defaults));
     if (CRM_Utils_Array::value('is_pay_later', $defaults)) {
         $this->assign('is_pay_later', TRUE);
     }
     if ($this->_mode) {
         // set default country from config if no country set
         $config = CRM_Core_Config::singleton();
         if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
         $defaults = array_merge($defaults, $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
         //             // hack to simplify credit card entry for testing
         //             $defaults['credit_card_type']     = 'Visa';
         //             $defaults['credit_card_number']   = '4807731747657838';
         //             $defaults['cvv2']                 = '000';
         //             $defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
     }
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Membership.php

示例2: setDefaultValues


//.........这里部分代码省略.........
             $this->_defaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
         }
         foreach ($names as $name) {
             if (!empty($this->_defaults[$name])) {
                 $this->_defaults["billing_" . $name] = $this->_defaults[$name];
             }
         }
     }
     //set custom field defaults set by admin if value is not set
     if (!empty($this->_fields)) {
         //set custom field defaults
         require_once "CRM/Core/BAO/CustomField.php";
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 if (!isset($this->_defaults[$name])) {
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, null, CRM_Profile_Form::MODE_REGISTER);
                 }
             }
         }
     }
     //set default membership for membershipship block
     require_once 'CRM/Member/BAO/Membership.php';
     if ($this->_membershipBlock) {
         $this->_defaults['selectMembership'] = $this->_defaultMemTypeId ? $this->_defaultMemTypeId : CRM_Utils_Array::value('membership_type_default', $this->_membershipBlock);
     }
     if ($this->_membershipContactID) {
         $this->_defaults['is_for_organization'] = 1;
         $this->_defaults['org_option'] = 1;
     } elseif ($this->_values['is_for_organization']) {
         $this->_defaults['org_option'] = 0;
     }
     if ($this->_values['is_for_organization'] && !isset($this->_defaults['location'][1]['email'][1]['email'])) {
         $this->_defaults['location'][1]['email'][1]['email'] = CRM_Utils_Array::value("email-{$this->_bltID}", $this->_defaults);
     }
     //if contribution pay later is enabled and payment
     //processor is not available then freeze the pay later checkbox with
     //default check
     if (CRM_Utils_Array::value('is_pay_later', $this->_values) && empty($this->_paymentProcessor)) {
         $this->_defaults['is_pay_later'] = 1;
     }
     //         // hack to simplify credit card entry for testing
     //         $this->_defaults['credit_card_type']     = 'Visa';
     //         $this->_defaults['amount']               = 168;
     //         $this->_defaults['credit_card_number']   = '4807731747657838';
     //         $this->_defaults['cvv2']                 = '000';
     //         $this->_defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
     //         // hack to simplify direct debit entry for testing
     //         $this->_defaults['account_holder'] = 'Max Müller';
     //         $this->_defaults['bank_account_number'] = '12345678';
     //         $this->_defaults['bank_identification_number'] = '12030000';
     //         $this->_defaults['bank_name'] = 'Bankname';
     //build set default for pledge overdue payment.
     if (CRM_Utils_Array::value('pledge_id', $this->_values)) {
         //get all payment statuses.
         $statuses = array();
         $returnProperties = array('status_id');
         CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_Payment', 'pledge_id', $this->_values['pledge_id'], $statuses, $returnProperties);
         require_once 'CRM/Contribute/PseudoConstant.php';
         $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus();
         $duePayment = false;
         foreach ($statuses as $payId => $value) {
             if ($paymentStatusTypes[$value['status_id']] == 'Overdue') {
                 $this->_defaults['pledge_amount'][$payId] = 1;
             } else {
                 if (!$duePayment && $paymentStatusTypes[$value['status_id']] == 'Pending') {
                     $this->_defaults['pledge_amount'][$payId] = 1;
                     $duePayment = true;
                 }
             }
         }
     } else {
         if (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
             //set default to one time contribution.
             $this->_defaults['is_pledge'] = 0;
         }
     }
     // to process Custom data that are appended to URL
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
     if (!empty($getDefaults)) {
         $this->_defaults = array_merge($this->_defaults, $getDefaults);
     }
     // now fix all state country selectors
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     if ($this->_priceSetId) {
         foreach ($this->_priceSet['fields'] as $key => $val) {
             foreach ($val['options'] as $keys => $values) {
                 if ($values['is_default']) {
                     if ($val['html_type'] == 'CheckBox') {
                         $this->_defaults["price_{$key}"][$keys] = 1;
                     } else {
                         $this->_defaults["price_{$key}"] = $keys;
                     }
                 }
             }
         }
     }
     return $this->_defaults;
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:101,代码来源:Main.php

示例3: 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 None
  */
 function setDefaultValues()
 {
     $defaults = $unsetSubmittedOptions = array();
     $discountId = NULL;
     //fix for CRM-3088, default value for discount set.
     if (!empty($this->_values['discount'])) {
         $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
         if ($discountId && CRM_Utils_Array::value('default_discount_fee_id', $this->_values['event'])) {
             $discountKey = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $this->_values['event']['default_discount_fee_id'], 'weight', 'id');
             $defaults['amount'] = key(array_slice($this->_values['discount'][$discountId], $discountKey - 1, $discountKey, TRUE));
         }
     }
     if ($this->_priceSetId) {
         foreach ($this->_feeBlock as $key => $val) {
             if (!CRM_Utils_Array::value('options', $val)) {
                 continue;
             }
             $optionsFull = CRM_Utils_Array::value('option_full_ids', $val, array());
             foreach ($val['options'] as $keys => $values) {
                 if ($values['is_default'] && !in_array($keys, $optionsFull)) {
                     if ($val['html_type'] == 'CheckBox') {
                         $defaults["price_{$key}"][$keys] = 1;
                     } else {
                         $defaults["price_{$key}"] = $keys;
                     }
                 }
             }
             if (!empty($optionsFull)) {
                 $unsetSubmittedOptions[$val['id']] = $optionsFull;
             }
         }
     }
     //CRM-4320, setdefault additional participant values.
     if ($this->_allowConfirmation && $this->_additionalParticipantId) {
         //hack to get set default from eventFees.php
         $this->_discountId = $discountId;
         $this->_pId = $this->_additionalParticipantId;
         $this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_additionalParticipantId, 'contact_id');
         $participantDefaults = CRM_Event_Form_EventFees::setDefaultValues($this);
         $participantDefaults = array_merge($this->_defaults, $participantDefaults);
         // use primary email address if billing email address is empty
         if (empty($this->_defaults["email-{$this->_bltID}"]) && !empty($this->_defaults["email-Primary"])) {
             $participantDefaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
         }
         $defaults = array_merge($defaults, $participantDefaults);
     }
     $defaults = array_merge($this->_defaults, $defaults);
     //reset values for all options those are full.
     if (!empty($unsetSubmittedOptions) && empty($_POST)) {
         $this->resetElementValue($unsetSubmittedOptions);
     }
     //load default campaign from page.
     if (array_key_exists('participant_campaign_id', $this->_fields)) {
         $defaults['participant_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
     }
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     return $defaults;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:66,代码来源:AdditionalParticipant.php

示例4: buildQuickForm


//.........这里部分代码省略.........
     if ($membershipTypeID) {
         $transactionID = $this->get('membership_trx_id');
         $membershipAmount = $this->get('membership_amount');
         $renewalMode = $this->get('renewal_mode');
         $this->assign('membership_trx_id', $transactionID);
         $this->assign('membership_amount', $membershipAmount);
         $this->assign('renewal_mode', $renewalMode);
         CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, FALSE, $membershipTypeID, TRUE, NULL, $this->_membershipContactID);
     }
     $this->_separateMembershipPayment = $this->get('separateMembershipPayment');
     $this->assign("is_separate_payment", $this->_separateMembershipPayment);
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
     $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
     if (CRM_Utils_Array::value('hidden_onbehalf_profile', $params)) {
         $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
         $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         $profileId = $OnBehalfProfile[0];
         $fieldTypes = array('Contact', 'Organization');
         $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
         $fieldTypes = array_merge($fieldTypes, $contactSubType);
         if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) {
             $fieldTypes = array_merge($fieldTypes, array('Membership'));
         } else {
             $fieldTypes = array_merge($fieldTypes, array('Contribution'));
         }
         $this->buildCustom($profileId, 'onbehalfProfile', TRUE, TRUE, $fieldTypes);
     }
     $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params));
     $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params)));
     $defaults = array();
     $options = array();
     $fields = array();
     $removeCustomFieldTypes = array('Contribution');
     foreach ($this->_fields as $name => $dontCare) {
         if ($name == 'onbehalf') {
             foreach ($dontCare as $key => $value) {
                 $fields['onbehalf'][$key] = 1;
             }
         } else {
             $fields[$name] = 1;
         }
     }
     $fields['state_province'] = $fields['country'] = $fields['email'] = 1;
     $contact = $this->_params = $this->controller->exportValues('Main');
     foreach ($fields as $name => $dontCare) {
         if ($name == 'onbehalf') {
             foreach ($dontCare as $key => $value) {
                 //$defaults[$key] = $contact['onbehalf'][$key];
                 if (isset($contact['onbehalf'][$key])) {
                     $defaults[$key] = $contact['onbehalf'][$key];
                 }
                 if (isset($contact['onbehalf']["{$key}_id"])) {
                     $defaults["{$key}_id"] = $contact['onbehalf']["{$key}_id"];
                 }
             }
         } elseif (isset($contact[$name])) {
             $defaults[$name] = $contact[$name];
             if (substr($name, 0, 7) == 'custom_') {
                 $timeField = "{$name}_time";
                 if (isset($contact[$timeField])) {
                     $defaults[$timeField] = $contact[$timeField];
                 }
             } elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting')) && CRM_Utils_Array::value($name . '_custom', $contact)) {
                 $defaults[$name . '_custom'] = $contact[$name . '_custom'];
             }
         }
     }
     // now fix all state country selectors
     CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     $this->_submitValues = array_merge($this->_submitValues, $defaults);
     $this->setDefaults($defaults);
     $values['entity_id'] = $this->_id;
     $values['entity_table'] = 'civicrm_contribution_page';
     CRM_Friend_BAO_Friend::retrieve($values, $data);
     $tellAFriend = FALSE;
     if ($this->_pcpId) {
         if ($this->_pcpBlock['is_tellfriend_enabled']) {
             $this->assign('friendText', ts('Tell a Friend'));
             $subUrl = "eid={$this->_pcpId}&blockId={$this->_pcpBlock['id']}&pcomponent=pcp";
             $tellAFriend = TRUE;
         }
     } elseif (CRM_Utils_Array::value('is_active', $data)) {
         $friendText = $data['title'];
         $this->assign('friendText', $friendText);
         $subUrl = "eid={$this->_id}&pcomponent=contribute";
         $tellAFriend = TRUE;
     }
     if ($tellAFriend) {
         if ($this->_action & CRM_Core_Action::PREVIEW) {
             $url = CRM_Utils_System::url("civicrm/friend", "reset=1&action=preview&{$subUrl}");
         } else {
             $url = CRM_Utils_System::url("civicrm/friend", "reset=1&{$subUrl}");
         }
         $this->assign('friendURL', $url);
     }
     $this->freeze();
     // can we blow away the session now to prevent hackery
     // CRM-9491
     $this->controller->reset();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:ThankYou.php

示例5: setDefaultValues


//.........这里部分代码省略.........
     }
     //         // hack to simplify credit card entry for testing
     //         $this->_defaults['credit_card_type']     = 'Visa';
     //         $this->_defaults['amount']               = 168;
     //         $this->_defaults['credit_card_number']   = '4111111111111111';
     //         $this->_defaults['cvv2']                 = '000';
     //         $this->_defaults['credit_card_exp_date'] = array('Y' => '2014', 'M' => '05');
     //         // hack to simplify direct debit entry for testing
     //         $this->_defaults['account_holder'] = 'Max Müller';
     //         $this->_defaults['bank_account_number'] = '12345678';
     //         $this->_defaults['bank_identification_number'] = '12030000';
     //         $this->_defaults['bank_name'] = 'Bankname';
     //build set default for pledge overdue payment.
     if (!empty($this->_values['pledge_id'])) {
         //get all pledge payment records of current pledge id.
         $pledgePayments = array();
         //used to record completed pledge payment ids used later for honor default
         $completedContributionIds = array();
         $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($this->_values['pledge_id']);
         $duePayment = FALSE;
         foreach ($pledgePayments as $payId => $value) {
             if ($value['status'] == 'Overdue') {
                 $this->_defaults['pledge_amount'][$payId] = 1;
             } elseif (!$duePayment && $value['status'] == 'Pending') {
                 $this->_defaults['pledge_amount'][$payId] = 1;
                 $duePayment = TRUE;
             } elseif ($value['status'] == 'Completed' && $value['contribution_id']) {
                 $completedContributionIds[] = $value['contribution_id'];
             }
         }
         if (!empty($this->_values['honor_block_is_active']) && count($completedContributionIds)) {
             $softCredit = array();
             foreach ($completedContributionIds as $id) {
                 $softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id);
             }
             if (isset($softCredit['soft_credit'])) {
                 $this->_defaults['soft_credit_type_id'] = $softCredit['soft_credit'][1]['soft_credit_type'];
                 //since honoree profile fieldname of fields are prefixed with 'honor'
                 //we need to reformat the fieldname to append prefix during setting default values
                 CRM_Core_BAO_UFGroup::setProfileDefaults($softCredit['soft_credit'][1]['contact_id'], CRM_Core_BAO_UFGroup::getFields($this->_honoreeProfileId), $defaults);
                 foreach ($defaults as $fieldName => $value) {
                     $this->_defaults['honor[' . $fieldName . ']'] = $value;
                 }
             }
         }
     } elseif (!empty($this->_values['pledge_block_id'])) {
         //set default to one time contribution.
         $this->_defaults['is_pledge'] = 0;
     }
     // to process Custom data that are appended to URL
     $getDefaults = CRM_Core_BAO_CustomGroup::extractGetParams($this, "'Contact', 'Individual', 'Contribution'");
     if (!empty($getDefaults)) {
         $this->_defaults = array_merge($this->_defaults, $getDefaults);
     }
     $config = CRM_Core_Config::singleton();
     // set default country from config if no country set
     if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
         $this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
     }
     // set default state/province from config if no state/province set
     if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
         $this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
     }
     // now fix all state country selectors
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     if ($this->_priceSetId) {
         if ($this->_useForMember && !empty($this->_currentMemberships) || $this->_defaultMemTypeId) {
             $selectedCurrentMemTypes = array();
             foreach ($this->_priceSet['fields'] as $key => $val) {
                 foreach ($val['options'] as $keys => $values) {
                     $opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values);
                     if ($opMemTypeId && in_array($opMemTypeId, $this->_currentMemberships) && !in_array($opMemTypeId, $selectedCurrentMemTypes)) {
                         if ($val['html_type'] == 'CheckBox') {
                             $this->_defaults["price_{$key}"][$keys] = 1;
                         } else {
                             $this->_defaults["price_{$key}"] = $keys;
                         }
                         $selectedCurrentMemTypes[] = $values['membership_type_id'];
                     } elseif (!empty($values['is_default']) && !$opMemTypeId && (!isset($this->_defaults["price_{$key}"]) || $val['html_type'] == 'CheckBox' && !isset($this->_defaults["price_{$key}"][$keys]))) {
                         if ($val['html_type'] == 'CheckBox') {
                             $this->_defaults["price_{$key}"][$keys] = 1;
                         } else {
                             $this->_defaults["price_{$key}"] = $keys;
                         }
                     }
                 }
             }
         } else {
             CRM_Price_BAO_PriceSet::setDefaultPriceSet($this, $this->_defaults);
         }
     }
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $pid => $value) {
             if (!empty($value['is_default'])) {
                 $this->_defaults['payment_processor'] = $pid;
             }
         }
     }
     return $this->_defaults;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例6: setDefaultValues

 /**
  * This function sets the default values for the form.
  *
  * @access public
  *
  * @return void
  */
 function setDefaultValues()
 {
     $this->_defaults = array();
     if ($this->_contactId) {
         CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $this->_contactProfileFields, $this->_defaults, TRUE);
         if ($this->_activityProfileId) {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $this->_activityProfileFields, $this->_defaults, TRUE);
         }
     }
     //set custom field defaults
     foreach ($this->_contactProfileFields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             $htmlType = $field['html_type'];
             if (!isset($this->_defaults[$name])) {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_contactId, $this->_mode);
             }
         }
     }
     if ($this->_activityProfileFields) {
         foreach ($this->_activityProfileFields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $htmlType = $field['html_type'];
                 if (!isset($this->_defaults[$name])) {
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_contactId, $this->_mode);
                 }
             }
         }
     }
     $this->setDefaults($this->_defaults);
     // add in all state country selectors for enabled countries
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:39,代码来源:Signature.php

示例7: setDefaultValues

 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = $this->_values;
     //set defaults for pledge payment.
     if ($this->_ppID) {
         $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
         $defaults['honor_type_id'] = CRM_Utils_Array::value('honor_type_id', $this->_pledgeValues);
         $defaults['honor_contact_id'] = CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues);
         $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues);
         $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
         $defaults['option_type'] = 1;
     }
     $fields = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     // set soft credit defaults
     CRM_Contribute_Form_SoftCredit::setDefaultValues($defaults, $this);
     if ($this->_mode) {
         $config = CRM_Core_Config::singleton();
         // set default country from config if no country set
         if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
         $defaults = array_merge($defaults, $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     }
     if ($this->_id) {
         $this->_contactID = $defaults['contact_id'];
     }
     // Set $newCredit variable in template to control whether link to credit card mode is included
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     // fix the display of the monetary value, CRM-4038
     if (isset($defaults['total_amount'])) {
         $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
     }
     if (isset($defaults['non_deductible_amount'])) {
         $defaults['non_deductible_amount'] = CRM_Utils_Money::format($defaults['non_deductible_amount'], NULL, '%a');
     }
     if (isset($defaults['fee_amount'])) {
         $defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a');
     }
     if (isset($defaults['net_amount'])) {
         $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a');
     }
     if ($this->_contributionType) {
         $defaults['financial_type_id'] = $this->_contributionType;
     }
     if (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
         $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     if (CRM_Utils_Array::value('is_test', $defaults)) {
         $this->assign('is_test', TRUE);
     }
     if (isset($defaults['honor_contact_id'])) {
         $honorDefault = $ids = array();
         $this->_honorID = $defaults['honor_contact_id'];
         $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
         $idParams = array('id' => $defaults['honor_contact_id'], 'contact_id' => $defaults['honor_contact_id']);
         CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $ids);
         $defaults['honor_prefix_id'] = CRM_Utils_Array::value('prefix_id', $honorDefault);
         $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
         $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
         $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
         $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
     }
     $this->assign('showOption', TRUE);
     // for Premium section
     if ($this->_premiumID) {
         $this->assign('showOption', FALSE);
         $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : "";
         if (!$options) {
             $this->assign('showOption', TRUE);
         }
         $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options);
         if ($options_key) {
             $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key));
         } else {
             $defaults['product_name'] = array($this->_productDAO->product_id);
         }
         if ($this->_productDAO->fulfilled_date) {
             list($defaults['fulfilled_date']) = CRM_Utils_Date::setDateDefaults($this->_productDAO->fulfilled_date);
         }
     }
     if (isset($this->userEmail)) {
         $this->assign('email', $this->userEmail);
     }
     if (CRM_Utils_Array::value('is_pay_later', $defaults)) {
         $this->assign('is_pay_later', TRUE);
     }
     $this->assign('contribution_status_id', CRM_Utils_Array::value('contribution_status_id', $defaults));
     $dates = array('receive_date', 'receipt_date', 'cancel_date', 'thankyou_date');
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Contribution.php

示例8: setDefaultValues

 public function setDefaultValues()
 {
     if ($this->_mode) {
         $defaults = $this->_values;
         $config = CRM_Core_Config::singleton();
         // set default country from config if no country set
         if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactId);
         $defaults = array_merge($defaults, $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     }
     // Set $newCredit variable in template to control whether link to credit card mode is included
     CRM_Core_Payment::allowBackofficeCreditCard($this);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:20,代码来源:AdditionalPayment.php

示例9: setDefaultValues

 /**
  * This function sets the default values for the form in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 static function setDefaultValues(&$form)
 {
     $defaults = array();
     if ($form->_eventId) {
         //get receipt text and financial type
         $returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date');
         $details = array();
         CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities);
         if (!empty($details[$form->_eventId]['financial_type_id'])) {
             $defaults[$form->_pId]['financial_type_id'] = $details[$form->_eventId]['financial_type_id'];
         }
     }
     if ($form->_pId) {
         $ids = array();
         $params = array('id' => $form->_pId);
         CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
         if ($form->_action == CRM_Core_Action::UPDATE) {
             $discounts = array();
             if (!empty($form->_values['discount'])) {
                 foreach ($form->_values['discount'] as $key => $value) {
                     $value = current($value);
                     $discounts[$key] = $value['name'];
                 }
             }
             if ($form->_discountId && !empty($discounts[$defaults[$form->_pId]['discount_id']])) {
                 $form->assign('discount', $discounts[$defaults[$form->_pId]['discount_id']]);
             }
             $form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
             $form->assign('fee_level', CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]));
         }
         $defaults[$form->_pId]['send_receipt'] = 0;
     } else {
         $defaults[$form->_pId]['send_receipt'] = strtotime(CRM_Utils_Array::value('start_date', $details[$form->_eventId])) >= time() ? 1 : 0;
         if ($form->_eventId && !empty($details[$form->_eventId]['confirm_email_text'])) {
             //set receipt text
             $defaults[$form->_pId]['receipt_text'] = $details[$form->_eventId]['confirm_email_text'];
         }
         list($defaults[$form->_pId]['receive_date']) = CRM_Utils_Date::setDateDefaults();
     }
     //CRM-11601 we should keep the record contribution
     //true by default while adding participant
     if ($form->_action == CRM_Core_Action::ADD && !$form->_mode && $form->_isPaidEvent) {
         $defaults[$form->_pId]['record_contribution'] = 1;
     }
     //CRM-13420
     if (empty($defaults['payment_instrument_id'])) {
         $defaults[$form->_pId]['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     if ($form->_mode) {
         $config = CRM_Core_Config::singleton();
         // set default country from config if no country set
         if (empty($defaults[$form->_pId]["billing_country_id-{$form->_bltID}"])) {
             $defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry;
         }
         if (empty($defaults["billing_state_province_id-{$form->_bltID}"])) {
             $defaults[$form->_pId]["billing_state_province_id-{$form->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $form->getProfileDefaults('Billing', $form->_contactId);
         $defaults[$form->_pId] = array_merge($defaults[$form->_pId], $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults[$form->_pId]);
         //             // hack to simplify credit card entry for testing
         //             $defaults[$form->_pId]['credit_card_type']     = 'Visa';
         //             $defaults[$form->_pId]['credit_card_number']   = '4807731747657838';
         //             $defaults[$form->_pId]['cvv2']                 = '000';
         //             $defaults[$form->_pId]['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
     }
     // if user has selected discount use that to set default
     if (isset($form->_discountId)) {
         $defaults[$form->_pId]['discount_id'] = $form->_discountId;
         //hack to set defaults for already selected discount value
         if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) {
             $form->_originalDiscountId = $defaults[$form->_pId]['discount_id'];
             if ($form->_originalDiscountId) {
                 $defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
             }
         }
         $discountId = $form->_discountId;
     } else {
         $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
     }
     if ($discountId) {
         $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Discount', $discountId, 'price_set_id');
     } else {
         $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $form->_eventId);
     }
     if ($form->_action == CRM_Core_Action::ADD && $form->_eventId && $discountId) {
         // this case is for add mode, where we show discount automatically
         $defaults[$form->_pId]['discount_id'] = $discountId;
     }
     if ($priceSetId) {
         // get price set default values, CRM-4090
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:EventFees.php

示例10: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $i18n = CRM_Core_I18n::singleton();
     CRM_Utils_System::setTitle(ts('Settings - Localization'));
     $locales = CRM_Core_I18n::languages();
     $warningTitle = json_encode(ts("Warning"));
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if ($domain->locales) {
         // for multi-lingual sites, populate default language drop-down with available languages
         $lcMessages = array();
         foreach ($locales as $loc => $lang) {
             if (substr_count($domain->locales, $loc)) {
                 $lcMessages[$loc] = $lang;
             }
         }
         $this->addElement('select', 'lcMessages', ts('Default Language'), $lcMessages);
         // add language limiter and language adder
         $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($lcMessages), NULL, NULL, NULL, NULL, '   ');
         $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff($locales, $lcMessages)));
         // add the ability to return to single language
         $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
     } else {
         // for single-lingual sites, populate default language drop-down with all languages
         $this->addElement('select', 'lcMessages', ts('Default Language'), $locales);
         $warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
         if ($validTriggerPermission && !$config->logging) {
             $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
         }
     }
     $this->addElement('checkbox', 'inheritLocale', ts('Inherit CMS Language'));
     $this->addElement('text', 'monetaryThousandSeparator', ts('Thousands Separator'), array('size' => 2));
     $this->addElement('text', 'monetaryDecimalPoint', ts('Decimal Delimiter'), array('size' => 2));
     $this->addElement('text', 'moneyformat', ts('Monetary Amount Display'));
     $this->addElement('text', 'moneyvalueformat', ts('Monetary Value Display'));
     $country = array();
     CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
     $i18n->localizeArray($country, array('context' => 'country'));
     asort($country);
     $includeCountry =& $this->addElement('advmultiselect', 'countryLimit', ts('Available Countries') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCountry->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCountry->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $includeState =& $this->addElement('advmultiselect', 'provinceLimit', ts('Available States and Provinces') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeState->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeState->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('select', 'defaultContactCountry', ts('Default Country'), array('' => ts('- select -')) + $country);
     /***Default State/Province***/
     $stateCountryMap = array();
     $stateCountryMap[] = array('state_province' => 'defaultContactStateProvince', 'country' => 'defaultContactCountry');
     $countryDefault = isset($this->_submitValues['defaultContactCountry']) ? $this->_submitValues['defaultContactCountry'] : $config->defaultContactCountry;
     if ($countryDefault) {
         $selectStateProvinceOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
     } else {
         $selectStateProvinceOptions = array('' => ts('- select a country -'));
     }
     $i18n->localizeArray($selectStateProvinceOptions, array('context' => 'state_province'));
     asort($selectStateProvinceOptions);
     $this->addElement('select', 'defaultContactStateProvince', ts('Default State/Province'), $selectStateProvinceOptions);
     // state country js
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     $defaults = array();
     CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults);
     // we do this only to initialize currencySymbols, kinda hackish but works!
     $config->defaultCurrencySymbol();
     $symbol = $config->currencySymbols;
     foreach ($symbol as $key => $value) {
         $this->_currencySymbols[$key] = "{$key}";
         if ($value) {
             $this->_currencySymbols[$key] .= " ({$value})";
         }
     }
     $this->addElement('select', 'defaultCurrency', ts('Default Currency'), $this->_currencySymbols);
     $includeCurrency =& $this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', $this->_currencySymbols, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('text', 'legacyEncoding', ts('Legacy Encoding'));
     $this->addElement('text', 'customTranslateFunction', ts('Custom Translate Function'));
     $this->addElement('text', 'fieldSeparator', ts('Import / Export Field Separator'), array('size' => 2));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
     parent::buildQuickForm();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:94,代码来源:Localization.php

示例11: buildForm

 function buildForm(&$form)
 {
     $config = CRM_Core_Config::singleton();
     $countryDefault = $config->defaultContactCountry;
     $form->add('text', 'distance', ts('Distance'), NULL, TRUE);
     $proxUnits = array('km' => ts('km'), 'miles' => ts('miles'));
     $form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, TRUE);
     $form->add('text', 'street_address', ts('Street Address'));
     $form->add('text', 'city', ts('City'));
     $form->add('text', 'postal_code', ts('Postal Code'));
     $stateCountryMap = array();
     $stateCountryMap[] = array('state_province' => 'state_province_id', 'country' => 'country_id');
     $defaults = array();
     if ($countryDefault) {
         $stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
         $defaults['country_id'] = $countryDefault;
     } else {
         $stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince();
     }
     $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince);
     $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
     $form->add('select', 'country_id', ts('Country'), $country, TRUE);
     $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
     $form->addElement('select', 'group', ts('Group'), $group);
     $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     $form->addElement('select', 'tag', ts('Tag'), $tag);
     // state country js, CRM-5233
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults);
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Proximity Search');
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('distance', 'prox_distance_unit', 'street_address', 'city', 'postal_code', 'country_id', 'state_province_id', 'group', 'tag'));
 }
开发者ID:hguru,项目名称:224Civi,代码行数:39,代码来源:Proximity.php

示例12: setDefaultValues

 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = $this->_values;
     //set defaults for pledge payment.
     if ($this->_ppID) {
         $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
         $defaults['honor_type_id'] = CRM_Utils_Array::value('honor_type_id', $this->_pledgeValues);
         $defaults['honor_contact_id'] = CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues);
         $defaults['contribution_type_id'] = CRM_Utils_Array::value('contribution_type_id', $this->_pledgeValues);
         $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues);
         $defaults['option_type'] = 1;
     }
     $fields = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     if ($this->_mode) {
         $billingFields = array();
         foreach ($this->_fields as $name => $dontCare) {
             if (strpos($name, 'billing_') === 0) {
                 $name = $idName = substr($name, 8);
                 if (in_array($name, array("state_province_id-{$this->_bltID}", "country_id-{$this->_bltID}"))) {
                     $name = str_replace('_id', '', $name);
                 }
                 $billingFields[$name] = 'billing_' . $idName;
             }
             $fields[$name] = 1;
         }
         if ($this->_contactID) {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $defaults);
         }
         foreach ($billingFields as $name => $billingName) {
             $defaults[$billingName] = CRM_Utils_Array::value($name, $defaults);
         }
         $config = CRM_Core_Config::singleton();
         // set default country from config if no country set
         if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         // now fix all state country selectors
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
         //             // hack to simplify credit card entry for testing
         //             $defaults['credit_card_type']     = 'Visa';
         //             $defaults['total_amount']         = 50;
         //             $defaults['credit_card_number']   = '4807731747657838';
         //             $defaults['cvv2']                 = '000';
         //             $defaults['credit_card_exp_date'] = array( 'Y' => '2012', 'M' => '05' );
     }
     if ($this->_id) {
         $this->_contactID = $defaults['contact_id'];
     }
     // fix the display of the monetary value, CRM-4038
     if (isset($defaults['total_amount'])) {
         $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a');
     }
     if (isset($defaults['non_deductible_amount'])) {
         $defaults['non_deductible_amount'] = CRM_Utils_Money::format($defaults['non_deductible_amount'], NULL, '%a');
     }
     if (isset($defaults['fee_amount'])) {
         $defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a');
     }
     if (isset($defaults['net_amount'])) {
         $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a');
     }
     if ($this->_contributionType) {
         $defaults['contribution_type_id'] = $this->_contributionType;
     }
     if (CRM_Utils_Array::value('is_test', $defaults)) {
         $this->assign('is_test', TRUE);
     }
     if (isset($defaults['honor_contact_id'])) {
         $honorDefault = $ids = array();
         $this->_honorID = $defaults['honor_contact_id'];
         $honorType = CRM_Core_PseudoConstant::honor();
         $idParams = array('id' => $defaults['honor_contact_id'], 'contact_id' => $defaults['honor_contact_id']);
         CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $ids);
         $defaults['honor_prefix_id'] = CRM_Utils_Array::value('prefix_id', $honorDefault);
         $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
         $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
         $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
         $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
     }
     $this->assign('showOption', TRUE);
     // for Premium section
     if ($this->_premiumID) {
         $this->assign('showOption', FALSE);
         $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : "";
         if (!$options) {
             $this->assign('showOption', TRUE);
         }
         $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options);
         if ($options_key) {
             $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key));
         } else {
             $defaults['product_name'] = array($this->_productDAO->product_id);
         }
         if ($this->_productDAO->fulfilled_date) {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Contribution.php

示例13: setDefaultValues

 /**
  * This function sets the default values for the form.
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 public function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = array();
     $defaults = parent::setDefaultValues();
     $this->_memType = $defaults['membership_type_id'];
     // set renewal_date and receive_date to today in correct input format (setDateDefaults uses today if no value passed)
     list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
     $defaults['renewal_date'] = $now;
     $defaults['receive_date'] = $now;
     $defaults['receive_date_time'] = $currentTime;
     if ($defaults['id']) {
         $defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $defaults['id'], 'contribution_id', 'membership_id');
     }
     if (is_numeric($this->_memType)) {
         $defaults['membership_type_id'] = array();
         $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
         $defaults['membership_type_id'][1] = $this->_memType;
     } else {
         $defaults['membership_type_id'] = $this->_memType;
     }
     $defaults['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
     //CRM-13420
     if (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
         $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     $defaults['total_amount'] = CRM_Utils_Money::format(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'), NULL, '%a');
     $defaults['record_contribution'] = 0;
     $defaults['num_terms'] = 1;
     $defaults['send_receipt'] = 0;
     $renewalDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('renewal_date', $defaults), NULL, NULL, 'Y-m-d');
     $this->assign('renewalDate', $renewalDate);
     $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
     if ($this->_mode) {
         // set default country from config if no country set
         $config = CRM_Core_Config::singleton();
         if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
         $defaults = array_merge($defaults, $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     }
     return $defaults;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:59,代码来源:MembershipRenewal.php

示例14: buildQuickForm


//.........这里部分代码省略.........
     if (!$userID) {
         require_once 'CRM/Core/BAO/LocationType.php';
         $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
         $primaryLocationType = $defaultLocationType->id;
         $anonUser = true;
         $this->assign('anonUser', true);
     }
     $addCaptcha = array();
     $emailPresent = false;
     // cache the state country fields. based on the results, we could use our javascript solution
     // in create or register mode
     $stateCountryMap = array();
     // add the form elements
     foreach ($this->_fields as $name => $field) {
         // make sure that there is enough permission to expose this field
         if (!$admin && $field['visibility'] == 'User and User Admin Only' || CRM_Utils_Array::value('is_view', $field)) {
             unset($this->_fields[$name]);
             continue;
         }
         // since the CMS manages the email field, suppress the email display if in
         // register mode which occur within the CMS form
         if ($this->_mode == self::MODE_REGISTER && substr($name, 0, 5) == 'email') {
             unset($this->_fields[$name]);
             continue;
         }
         list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
         if ($prefixName == 'state_province' || $prefixName == 'country') {
             if (!array_key_exists($index, $stateCountryMap)) {
                 $stateCountryMap[$index] = array();
             }
             $stateCountryMap[$index][$prefixName] = $name;
         }
         CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
         if ($field['add_to_group_id']) {
             $addToGroupId = $field['add_to_group_id'];
         }
         //build array for captcha
         if ($field['add_captcha']) {
             $addCaptcha[$field['group_id']] = $field['add_captcha'];
         }
         if ($name == 'email-Primary' || ($name == 'email-' . isset($primaryLocationType) ? $primaryLocationType : "")) {
             $emailPresent = true;
             $this->_mail = $name;
         }
     }
     $setCaptcha = false;
     // do this only for CiviCRM created forms
     if ($this->_mode == self::MODE_CREATE) {
         if (!empty($addCaptcha)) {
             $setCaptcha = true;
         }
         if ($this->_gid) {
             $dao = new CRM_Core_DAO_UFGroup();
             $dao->id = $this->_gid;
             $dao->addSelect();
             $dao->addSelect('add_captcha', 'is_update_dupe');
             if ($dao->find(true)) {
                 if ($dao->add_captcha) {
                     $setCaptcha = true;
                 }
                 if ($dao->is_update_dupe) {
                     $this->_isUpdateDupe = true;
                 }
             }
         }
         if ($setCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", true);
         }
     }
     if ($this->_mode != self::MODE_SEARCH) {
         if (isset($addToGroupId)) {
             $this->add('hidden', "group[{$addToGroupId}]", 1);
             $this->_addToGroupID = $addToGroupId;
         }
     }
     // also do state country js
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap, $this->_defaults);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, null);
     if ($this->_mode == self::MODE_CREATE) {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $this->_gid, $emailPresent, $action);
     } else {
         $this->assign('showCMS', false);
     }
     $this->assign('groupId', $this->_gid);
     // now fix all state country selectors
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
     if ($this->_context == 'dialog') {
         $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Form.php

示例15: 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 None
  */
 function setDefaultValues()
 {
     $contactID = parent::getContactID();
     if ($contactID) {
         $options = array();
         $fields = array();
         require_once "CRM/Core/BAO/CustomGroup.php";
         if (!empty($this->_fields)) {
             $removeCustomFieldTypes = array('Participant');
             foreach ($this->_fields as $name => $dontCare) {
                 if (substr($name, 0, 7) == 'custom_') {
                     $id = substr($name, 7);
                     if (!$this->_allowConfirmation && !CRM_Core_BAO_CustomGroup::checkCustomField($id, $removeCustomFieldTypes)) {
                         continue;
                     }
                 } else {
                     if (substr($name, 0, 12) == 'participant_') {
                         //ignore component fields
                         continue;
                     }
                 }
                 $fields[$name] = 1;
             }
         }
         $names = array("first_name", "middle_name", "last_name", "street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}", "state_province_id-{$this->_bltID}");
         foreach ($names as $name) {
             $fields[$name] = 1;
         }
         $fields["state_province-{$this->_bltID}"] = 1;
         $fields["country-{$this->_bltID}"] = 1;
         $fields["email-{$this->_bltID}"] = 1;
         $fields["email-Primary"] = 1;
         require_once 'CRM/Core/BAO/UFGroup.php';
         CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults);
         // use primary email address if billing email address is empty
         if (empty($this->_defaults["email-{$this->_bltID}"]) && !empty($this->_defaults["email-Primary"])) {
             $this->_defaults["email-{$this->_bltID}"] = $this->_defaults["email-Primary"];
         }
         foreach ($names as $name) {
             if (isset($this->_defaults[$name])) {
                 $this->_defaults["billing_" . $name] = $this->_defaults[$name];
             }
         }
     }
     //if event is monetary and pay later is enabled and payment
     //processor is not available then freeze the pay later checkbox with
     //default check
     if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) && !is_array($this->_paymentProcessor)) {
         $this->_defaults['is_pay_later'] = 1;
     }
     //set custom field defaults
     if (!empty($this->_fields)) {
         require_once "CRM/Core/BAO/CustomField.php";
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 if (!isset($this->_defaults[$name])) {
                     //fix for CRM-1743
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, null, CRM_Profile_Form::MODE_REGISTER);
                 }
             }
         }
     }
     //fix for CRM-3088, default value for discount set.
     $discountId = null;
     if (!empty($this->_values['discount'])) {
         require_once 'CRM/Core/BAO/Discount.php';
         $discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
         if ($discountId) {
             if (isset($this->_values['event']['default_discount_fee_id'])) {
                 $discountKey = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $this->_values['event']['default_discount_fee_id'], 'weight', 'id');
                 $this->_defaults['amount'] = key(array_slice($this->_values['discount'][$discountId], $discountKey - 1, $discountKey, true));
             }
         }
     }
     $config = CRM_Core_Config::singleton();
     // set default country from config if no country set
     if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $this->_defaults)) {
         $this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
     }
     // now fix all state country selectors
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     // add this event's default participant role to defaults array (for cases where participant_role field is included in form via profile)
     if ($this->_values['event']['default_role_id']) {
         $this->_defaults['participant_role_id'] = $this->_values['event']['default_role_id'];
     }
     if ($this->_priceSetId) {
         foreach ($this->_feeBlock as $key => $val) {
             foreach ($val['options'] as $keys => $values) {
                 if ($values['is_default'] && !CRM_Utils_Array::value('is_full', $values)) {
                     if ($val['html_type'] == 'CheckBox') {
                         $this->_defaults["price_{$key}"][$keys] = 1;
                     } else {
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Register.php


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