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


PHP CRM_Utils_Address类代码示例

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


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

示例1: evaluateToken

 /**
  * Evaluate the content of a single token.
  *
  * @param \Civi\Token\TokenRow $row
  *   The record for which we want token values.
  * @param string $field
  *   The name of the token field.
  * @param mixed $prefetch
  *   Any data that was returned by the prefetch().
  * @return mixed
  */
 public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL)
 {
     $actionSearchResult = $row->context['actionSearchResult'];
     if ($field == 'location') {
         $loc = array();
         $stateProvince = \CRM_Core_PseudoConstant::stateProvince();
         $loc['street_address'] = $actionSearchResult->street_address;
         $loc['city'] = $actionSearchResult->city;
         $loc['state_province'] = \CRM_Utils_Array::value($actionSearchResult->state_province_id, $stateProvince);
         $loc['postal_code'] = $actionSearchResult->postal_code;
         //$entityTokenParams[$tokenEntity][$field] = \CRM_Utils_Address::format($loc);
         $row->tokens($entity, $field, \CRM_Utils_Address::format($loc));
     } elseif ($field == 'info_url') {
         $row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE));
     } elseif ($field == 'registration_url') {
         $row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE));
     } elseif (in_array($field, array('start_date', 'end_date'))) {
         $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->{$field}));
     } elseif ($field == 'balance') {
         if ($actionSearchResult->entityTable == 'civicrm_contact') {
             $balancePay = 'N/A';
         } elseif (!empty($actionSearchResult->entityID)) {
             $info = \CRM_Contribute_BAO_Contribution::getPaymentInfo($actionSearchResult->entityID, 'event');
             $balancePay = \CRM_Utils_Array::value('balance', $info);
             $balancePay = \CRM_Utils_Money::format($balancePay);
         }
         $row->tokens($entity, $field, $balancePay);
     } elseif ($field == 'fee_amount') {
         $row->tokens($entity, $field, \CRM_Utils_Money::format($actionSearchResult->{$field}));
     } elseif (isset($actionSearchResult->{$field})) {
         $row->tokens($entity, $field, $actionSearchResult->{$field});
     } else {
         $row->tokens($entity, $field, '');
     }
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:46,代码来源:Tokens.php

示例2: format

 /**
  * function that takes an address object and gets the latitude / longitude for this
  * address. Note that at a later stage, we could make this function also clean up
  * the address into a more valid format
  *
  * @param object $address
  *
  * @return boolean true if we modified the address, false otherwise
  * @static
  */
 function format(&$values)
 {
     require_once 'CRM/Utils/Address.php';
     // we need a valid zipcode, state and country, else we ignore
     if (!CRM_Utils_Array::value('postal_code', $values) && !CRM_Utils_Array::value('state_province', $values) && !CRM_Utils_Array::value('country', $values)) {
         return false;
     }
     if ($values['country'] != 'United States') {
         return false;
     }
     $string = CRM_Utils_Address::format($values);
     $string = str_replace("\n", ', ', $string);
     if (!$string) {
         return false;
     }
     $params = array(new XML_RPC_Value($string, 'string'));
     $message = new XML_RPC_Message('geocode', $params);
     $client = new XML_RPC_Client($GLOBALS['_CRM_UTILS_GEOCODE_RPC']['_uri'], $GLOBALS['_CRM_UTILS_GEOCODE_RPC']['_server']);
     $response = $client->send($message);
     if (!$response && !$response->faultCode()) {
         return false;
     }
     $data = XML_RPC_decode($response->value());
     if (!CRM_Utils_Array::value(0, $data)) {
         return false;
     }
     $data = $data[0];
     $values['geo_code_1'] = $data['lat'];
     $values['geo_code_2'] = $data['long'];
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:41,代码来源:RPC.php

示例3: testAddressFormat

 public function testAddressFormat()
 {
     $contact = $this->callAPISuccess('contact', 'create', array('first_name' => 'Micky', 'last_name' => 'mouse', 'contact_type' => 'Individual'));
     $address = $this->callAPISuccess('address', 'create', array('street_address' => '1 Happy Place', 'city' => 'Miami', 'state_province' => 'Flordia', 'country' => 'United States', 'postal_code' => 33101, 'contact_id' => $contact['id'], 'location_type_id' => 5, 'is_primary' => 1));
     $addressDetails = $address['values'][$address['id']];
     $countries = CRM_Core_PseudoConstant::country();
     $addressDetails['country'] = $countries[$addressDetails['country_id']];
     $formatted_address = CRM_Utils_Address::format($addressDetails, 'mailing_format', FALSE, TRUE);
     $this->assertTrue((bool) strstr($formatted_address, 'UNITED STATES'));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:10,代码来源:AddressTest.php

示例4: updateConstructedNames

 public function updateConstructedNames()
 {
     require_once 'CRM/Utils/Address.php';
     require_once 'CRM/Core/BAO/Preferences.php';
     require_once 'CRM/Core/DAO.php';
     require_once 'CRM/Core/PseudoConstant.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     //handle individuals using settings in the system
     $query = "SELECT * FROM civicrm_contact WHERE contact_type = 'Individual';";
     $dao = CRM_Core_DAO::executeQuery($query);
     $prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
     $suffixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
     $tokens = array();
     CRM_Utils_Hook::tokens($tokens);
     $tokenFields = array();
     foreach ($tokens as $category => $catTokens) {
         foreach ($catTokens as $token) {
             $tokenFields[] = $token;
         }
     }
     //determine sort name construction
     $sortFormat = CRM_Core_BAO_Preferences::value('sort_name_format');
     $sortFormat = str_replace('contact.', '', $sortFormat);
     //determine display name construction
     $displayFormat = CRM_Core_BAO_Preferences::value('display_name_format');
     $displayFormat = str_replace('contact.', '', $displayFormat);
     while ($dao->fetch()) {
         $contactID = $dao->id;
         $params = array('first_name' => $dao->first_name, 'middle_name' => $dao->middle_name, 'last_name' => $dao->last_name, 'prefix_id' => $dao->prefix_id, 'suffix_id' => $dao->suffix_id);
         $params['individual_prefix'] = $prefixes[$dao->prefix_id];
         $params['individual_suffix'] = $suffixes[$dao->suffix_id];
         $sortName = CRM_Utils_Address::format($params, $sortFormat, FALSE, FALSE, TRUE, $tokenFields);
         $sortName = trim(CRM_Core_DAO::escapeString($sortName));
         $displayName = CRM_Utils_Address::format($params, $displayFormat, FALSE, FALSE, TRUE, $tokenFields);
         $displayName = trim(CRM_Core_DAO::escapeString($displayName));
         //check for email
         if (empty($sortName) || empty($displayName)) {
             $email = NULL;
             $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contactID);
             if (empty($email)) {
                 $email = $contactID;
             }
             if (empty($sortName)) {
                 $sortName = $email;
             }
             if (empty($displayName)) {
                 $displayName = $email;
             }
         }
         //update record
         $updateQuery = "UPDATE civicrm_contact SET display_name = '{$displayName}', sort_name = '{$sortName}' WHERE id = {$contactID};";
         CRM_Core_DAO::executeQuery($updateQuery);
     }
     //end indiv
     echo "\n Individuals recached... ";
     //set organizations
     $query = "UPDATE civicrm_contact\n\t\t          SET display_name = organization_name,\n\t\t\t\t      sort_name = organization_name\n\t\t\t      WHERE contact_type = 'Organization';";
     $dao = CRM_Core_DAO::executeQuery($query);
     echo "\n Organizations recached... ";
     //set households
     $query = "UPDATE civicrm_contact\n\t\t          SET display_name = household_name,\n\t\t\t\t      sort_name = household_name\n\t\t\t      WHERE contact_type = 'Household';";
     $dao = CRM_Core_DAO::executeQuery($query);
     echo "\n Households recached... ";
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:64,代码来源:updateNameCache.php

示例5: AND

 /**
  * function to get the complete information for one or more events
  *
  * @param  date    $start      get events with start date >= this date
  * @param  integer $type       get events on the a specific event type (by event_type_id)
  * @param  integer $eventId    return a single event - by event id
  * @param  date    $end        also get events with end date >= this date
  * @param  boolean $onlyPublic include public events only, default TRUE
  *
  * @return  array  $all      array of all the events that are searched
  * @static
  * @access public
  */
 static function &getCompleteInfo($start = NULL, $type = NULL, $eventId = NULL, $end = NULL, $onlyPublic = TRUE)
 {
     $publicCondition = NULL;
     if ($onlyPublic) {
         $publicCondition = "  AND civicrm_event.is_public = 1";
     }
     $dateCondition = '';
     // if start and end date are NOT passed, return all events with start_date OR end_date >= today CRM-5133
     if ($start) {
         // get events with start_date >= requested start
         $startDate = CRM_Utils_Type::escape($start, 'Date');
         $dateCondition .= " AND ( civicrm_event.start_date >= {$startDate} )";
     }
     if ($end) {
         // also get events with end_date <= requested end
         $endDate = CRM_Utils_Type::escape($end, 'Date');
         $dateCondition .= " AND ( civicrm_event.end_date <= '{$endDate}' ) ";
     }
     // CRM-9421 and CRM-8620 Default mode for ical/rss feeds. No start or end filter passed.
     // Need to exclude old events with only start date
     // and not exclude events in progress (start <= today and end >= today). DGG
     if (empty($start) && empty($end)) {
         // get events with end date >= today, not sure of this logic
         // but keeping this for backward compatibility as per issue CRM-5133
         $today = date("Y-m-d G:i:s");
         $dateCondition .= " AND ( civicrm_event.end_date >= '{$today}' OR civicrm_event.start_date >= '{$today}' ) ";
     }
     if ($type) {
         $typeCondition = " AND civicrm_event.event_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
     }
     // Get the Id of Option Group for Event Types
     $optionGroupDAO = new CRM_Core_DAO_OptionGroup();
     $optionGroupDAO->name = 'event_type';
     $optionGroupId = NULL;
     if ($optionGroupDAO->find(TRUE)) {
         $optionGroupId = $optionGroupDAO->id;
     }
     $query = "\nSELECT\n  civicrm_event.id as event_id,\n  civicrm_email.email as email,\n  civicrm_event.title as title,\n  civicrm_event.summary as summary,\n  civicrm_event.start_date as start,\n  civicrm_event.end_date as end,\n  civicrm_event.description as description,\n  civicrm_event.is_show_location as is_show_location,\n  civicrm_event.is_online_registration as is_online_registration,\n  civicrm_event.registration_link_text as registration_link_text,\n  civicrm_event.registration_start_date as registration_start_date,\n  civicrm_event.registration_end_date as registration_end_date,\n  civicrm_option_value.label as event_type,\n  civicrm_address.name as address_name,\n  civicrm_address.street_address as street_address,\n  civicrm_address.supplemental_address_1 as supplemental_address_1,\n  civicrm_address.supplemental_address_2 as supplemental_address_2,\n  civicrm_address.city as city,\n  civicrm_address.postal_code as postal_code,\n  civicrm_address.postal_code_suffix as postal_code_suffix,\n  civicrm_state_province.abbreviation as state,\n  civicrm_country.name AS country\nFROM civicrm_event\nLEFT JOIN civicrm_loc_block ON civicrm_event.loc_block_id = civicrm_loc_block.id\nLEFT JOIN civicrm_address ON civicrm_loc_block.address_id = civicrm_address.id\nLEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id\nLEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id\nLEFT JOIN civicrm_email ON civicrm_loc_block.email_id = civicrm_email.id\nLEFT JOIN civicrm_option_value ON (\n                                    civicrm_event.event_type_id = civicrm_option_value.value AND\n                                    civicrm_option_value.option_group_id = %1 )\nWHERE civicrm_event.is_active = 1\n      AND (is_template = 0 OR is_template IS NULL)\n      {$publicCondition}\n      {$dateCondition}";
     if (isset($typeCondition)) {
         $query .= $typeCondition;
     }
     if (isset($eventId)) {
         $query .= " AND civicrm_event.id ={$eventId} ";
     }
     $query .= " ORDER BY   civicrm_event.start_date ASC";
     $params = array(1 => array($optionGroupId, 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     $all = array();
     $config = CRM_Core_Config::singleton();
     $baseURL = parse_url($config->userFrameworkBaseURL);
     $url = "@" . $baseURL['host'];
     if (!empty($baseURL['path'])) {
         $url .= substr($baseURL['path'], 0, -1);
     }
     // check 'view event info' permission
     //@todo - per CRM-14626 we have resolved that 'view event info' means 'view ALL event info'
     // and passing in the specific permission here will short-circuit the evaluation of permission to
     // see specific events (doesn't seem relevant to this call
     // however, since this function is accessed only by a convoluted call from a joomla block function
     // it seems safer not to touch here. Suggestion is that CRM_Core_Permission::check(array or relevant permissions) would
     // be clearer & safer here
     $permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
     // check if we're in shopping cart mode for events
     $enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
     if ($enable_cart) {
     }
     while ($dao->fetch()) {
         if (!empty($permissions) && in_array($dao->event_id, $permissions)) {
             $info = array();
             $info['uid'] = "CiviCRM_EventID_{$dao->event_id}_" . md5($config->userFrameworkBaseURL) . $url;
             $info['title'] = $dao->title;
             $info['event_id'] = $dao->event_id;
             $info['summary'] = $dao->summary;
             $info['description'] = $dao->description;
             $info['start_date'] = $dao->start;
             $info['end_date'] = $dao->end;
             $info['contact_email'] = $dao->email;
             $info['event_type'] = $dao->event_type;
             $info['is_show_location'] = $dao->is_show_location;
             $info['is_online_registration'] = $dao->is_online_registration;
             $info['registration_link_text'] = $dao->registration_link_text;
             $info['registration_start_date'] = $dao->registration_start_date;
             $info['registration_end_date'] = $dao->registration_end_date;
             $address = '';
             $addrFields = array('address_name' => $dao->address_name, 'street_address' => $dao->street_address, 'supplemental_address_1' => $dao->supplemental_address_1, 'supplemental_address_2' => $dao->supplemental_address_2, 'city' => $dao->city, 'state_province' => $dao->state, 'postal_code' => $dao->postal_code, 'postal_code_suffix' => $dao->postal_code_suffix, 'country' => $dao->country, 'county' => NULL);
             CRM_Utils_String::append($address, ', ', CRM_Utils_Address::format($addrFields));
             $info['location'] = $address;
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Event.php

示例6: emailReceipt

 /**
  * Send email receipt.
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param array $formValues
  * @param object $membership
  *   Object.
  *
  * @return bool
  *   true if mail was sent successfully
  */
 public static function emailReceipt(&$form, &$formValues, &$membership)
 {
     // retrieve 'from email id' for acknowledgement
     $receiptFrom = $formValues['from_email_address'];
     if (!empty($formValues['payment_instrument_id'])) {
         $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
         $formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
     }
     // retrieve custom data
     $customFields = $customValues = array();
     if (property_exists($form, '_groupTree') && !empty($form->_groupTree)) {
         foreach ($form->_groupTree as $groupID => $group) {
             if ($groupID == 'info') {
                 continue;
             }
             foreach ($group['fields'] as $k => $field) {
                 $field['title'] = $field['label'];
                 $customFields["custom_{$k}"] = $field;
             }
         }
     }
     $members = array(array('member_id', '=', $membership->id, 0, 0));
     // check whether its a test drive
     if ($form->_mode == 'test') {
         $members[] = array('member_test', '=', 1, 0, 0);
     }
     CRM_Core_BAO_UFGroup::getValues($formValues['contact_id'], $customFields, $customValues, FALSE, $members);
     if ($form->_mode) {
         if (!empty($form->_params['billing_first_name'])) {
             $name = $form->_params['billing_first_name'];
         }
         if (!empty($form->_params['billing_middle_name'])) {
             $name .= " {$form->_params['billing_middle_name']}";
         }
         if (!empty($form->_params['billing_last_name'])) {
             $name .= " {$form->_params['billing_last_name']}";
         }
         $form->assign('billingName', $name);
         // assign the address formatted up for display
         $addressParts = array("street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "state_province-{$form->_bltID}", "country-{$form->_bltID}");
         $addressFields = array();
         foreach ($addressParts as $part) {
             list($n, $id) = explode('-', $part);
             if (isset($form->_params['billing_' . $part])) {
                 $addressFields[$n] = $form->_params['billing_' . $part];
             }
         }
         $form->assign('address', CRM_Utils_Address::format($addressFields));
         $date = CRM_Utils_Date::format($form->_params['credit_card_exp_date']);
         $date = CRM_Utils_Date::mysqlToIso($date);
         $form->assign('credit_card_exp_date', $date);
         $form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($form->_params['credit_card_number']));
         $form->assign('credit_card_type', $form->_params['credit_card_type']);
         $form->assign('contributeMode', 'direct');
         $form->assign('isAmountzero', 0);
         $form->assign('is_pay_later', 0);
         $form->assign('isPrimary', 1);
     }
     $form->assign('module', 'Membership');
     $form->assign('contactID', $formValues['contact_id']);
     $form->assign('membershipID', CRM_Utils_Array::value('membership_id', $form->_params, CRM_Utils_Array::value('membership_id', $form->_defaultValues)));
     if (!empty($formValues['contribution_id'])) {
         $form->assign('contributionID', $formValues['contribution_id']);
     } elseif (isset($form->_onlinePendingContributionId)) {
         $form->assign('contributionID', $form->_onlinePendingContributionId);
     }
     if (!empty($formValues['contribution_status_id'])) {
         $form->assign('contributionStatusID', $formValues['contribution_status_id']);
         $form->assign('contributionStatus', CRM_Contribute_PseudoConstant::contributionStatus($formValues['contribution_status_id'], 'name'));
     }
     if (!empty($formValues['is_renew'])) {
         $form->assign('receiptType', 'membership renewal');
     } else {
         $form->assign('receiptType', 'membership signup');
     }
     $form->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $formValues)));
     $form->assign('formValues', $formValues);
     if (empty($lineItem)) {
         $form->assign('mem_start_date', CRM_Utils_Date::customFormat($membership->start_date, '%B %E%f, %Y'));
         if (!CRM_Utils_System::isNull($membership->end_date)) {
             $form->assign('mem_end_date', CRM_Utils_Date::customFormat($membership->end_date, '%B %E%f, %Y'));
         }
         $form->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
     }
     $form->assign('customValues', $customValues);
     $isBatchProcess = is_a($form, 'CRM_Batch_Form_Entry');
     if (empty($form->_contributorDisplayName) || empty($form->_contributorEmail) || $isBatchProcess) {
         // in this case the form is being called statically from the batch editing screen
//.........这里部分代码省略.........
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php

示例7: assignToTemplate

 /**
  * Assign the minimal set of variables to the template.
  */
 public function assignToTemplate()
 {
     $name = CRM_Utils_Array::value('billing_first_name', $this->_params);
     if (!empty($this->_params['billing_middle_name'])) {
         $name .= " {$this->_params['billing_middle_name']}";
     }
     $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
     $name = trim($name);
     $this->assign('billingName', $name);
     $this->set('name', $name);
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     $vars = array('amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level');
     $config = CRM_Core_Config::singleton();
     if (isset($this->_values['is_recur']) && !empty($this->_paymentProcessor['is_recur'])) {
         $this->assign('is_recur_enabled', 1);
         $vars = array_merge($vars, array('is_recur', 'frequency_interval', 'frequency_unit', 'installments'));
     }
     if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('is_pledge', $this->_params) == 1) {
         $this->assign('pledge_enabled', 1);
         $vars = array_merge($vars, array('is_pledge', 'pledge_frequency_interval', 'pledge_frequency_unit', 'pledge_installments'));
     }
     // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
     // function to get correct amount level consistently. Remove setting of the amount level in
     // CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest
     // to cover all variants.
     if (isset($this->_params['amount_other']) || isset($this->_params['selectMembership'])) {
         $this->_params['amount_level'] = '';
     }
     foreach ($vars as $v) {
         if (isset($this->_params[$v])) {
             if ($v == "amount" && $this->_params[$v] === 0) {
                 $this->_params[$v] = CRM_Utils_Money::format($this->_params[$v], NULL, NULL, TRUE);
             }
             $this->assign($v, $this->_params[$v]);
         }
     }
     // assign the address formatted up for display
     $addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
     $addressFields = array();
     foreach ($addressParts as $part) {
         list($n, $id) = explode('-', $part);
         $addressFields[$n] = CRM_Utils_Array::value('billing_' . $part, $this->_params);
     }
     $this->assign('address', CRM_Utils_Address::format($addressFields));
     if (!empty($this->_params['onbehalf_profile_id']) && !empty($this->_params['onbehalf'])) {
         $this->assign('onBehalfName', $this->_params['organization_name']);
         $locTypeId = array_keys($this->_params['onbehalf_location']['email']);
         $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
     }
     //fix for CRM-3767
     $assignCCInfo = FALSE;
     if ($this->_amount > 0.0) {
         $assignCCInfo = TRUE;
     } elseif (!empty($this->_params['selectMembership'])) {
         $memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee');
         if ($memFee > 0.0) {
             $assignCCInfo = TRUE;
         }
     }
     // The concept of contributeMode is deprecated.
     // The payment processor object can provide info about the fields it shows.
     if ($this->_contributeMode == 'direct' && $assignCCInfo) {
         if ($this->_paymentProcessor && $this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
             $this->assign('account_holder', $this->_params['account_holder']);
             $this->assign('bank_identification_number', $this->_params['bank_identification_number']);
             $this->assign('bank_name', $this->_params['bank_name']);
             $this->assign('bank_account_number', $this->_params['bank_account_number']);
         } else {
             $date = CRM_Utils_Date::format(CRM_Utils_array::value('credit_card_exp_date', $this->_params));
             $date = CRM_Utils_Date::mysqlToIso($date);
             $this->assign('credit_card_exp_date', $date);
             $this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard(CRM_Utils_array::value('credit_card_number', $this->_params)));
         }
     }
     $this->assign('email', $this->controller->exportValue('Main', "email-{$this->_bltID}"));
     // also assign the receipt_text
     if (isset($this->_values['receipt_text'])) {
         $this->assign('receipt_text', $this->_values['receipt_text']);
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:83,代码来源:ContributionBase.php

示例8: _assignMessageVariablesToTemplate

 /**
  * Apply variables for message to smarty template - this function is part of analysing what is in the huge
  * function & breaking it down into manageable chunks. Eventually it will be refactored into something else
  * Note we send directly from this function in some cases because it is only partly refactored
  * Don't call this function directly as the signature will change
  *
  * @param $values
  * @param $input
  * @param CRM_Core_SMARTY $template
  * @param bool $recur
  * @param bool $returnMessageText
  *
  * @return mixed
  */
 public function _assignMessageVariablesToTemplate(&$values, $input, &$template, $recur = FALSE, $returnMessageText = TRUE)
 {
     $template->assign('first_name', $this->_relatedObjects['contact']->first_name);
     $template->assign('last_name', $this->_relatedObjects['contact']->last_name);
     $template->assign('displayName', $this->_relatedObjects['contact']->display_name);
     if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) {
         $template->assign('useForMember', TRUE);
     }
     //assign honor information to receipt message
     $softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
     if (isset($softRecord['soft_credit'])) {
         //if id of contribution page is present
         if (!empty($values['id'])) {
             $values['honor'] = array('honor_profile_values' => array(), 'honor_profile_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'uf_group_id', 'entity_id'), 'honor_id' => $softRecord['soft_credit'][1]['contact_id']);
             $softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type');
             $template->assign('soft_credit_type', $softRecord['soft_credit'][1]['soft_credit_type_label']);
             $template->assign('honor_block_is_active', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFJoin', $values['id'], 'is_active', 'entity_id'));
         } else {
             //offline contribution
             $softCreditTypes = $softCredits = array();
             foreach ($softRecord['soft_credit'] as $key => $softCredit) {
                 $softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
                 $softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']));
             }
             $template->assign('softCreditTypes', $softCreditTypes);
             $template->assign('softCredits', $softCredits);
         }
     }
     $dao = new CRM_Contribute_DAO_ContributionProduct();
     $dao->contribution_id = $this->id;
     if ($dao->find(TRUE)) {
         $premiumId = $dao->product_id;
         $template->assign('option', $dao->product_option);
         $productDAO = new CRM_Contribute_DAO_Product();
         $productDAO->id = $premiumId;
         $productDAO->find(TRUE);
         $template->assign('selectPremium', TRUE);
         $template->assign('product_name', $productDAO->name);
         $template->assign('price', $productDAO->price);
         $template->assign('sku', $productDAO->sku);
     }
     $template->assign('title', CRM_Utils_Array::value('title', $values));
     $amount = CRM_Utils_Array::value('total_amount', $input, CRM_Utils_Array::value('amount', $input), NULL);
     if (empty($amount) && isset($this->total_amount)) {
         $amount = $this->total_amount;
     }
     $template->assign('amount', $amount);
     // add the new contribution values
     if (strtolower($this->_component) == 'contribute') {
         //PCP Info
         $softDAO = new CRM_Contribute_DAO_ContributionSoft();
         $softDAO->contribution_id = $this->id;
         if ($softDAO->find(TRUE)) {
             $template->assign('pcpBlock', TRUE);
             $template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
             $template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
             $template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
             //assign the pcp page title for email subject
             $pcpDAO = new CRM_PCP_DAO_PCP();
             $pcpDAO->id = $softDAO->pcp_id;
             if ($pcpDAO->find(TRUE)) {
                 $template->assign('title', $pcpDAO->title);
             }
         }
     }
     if ($this->financial_type_id) {
         $values['financial_type_id'] = $this->financial_type_id;
     }
     $template->assign('trxn_id', $this->trxn_id);
     $template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date));
     $template->assign('contributeMode', 'notify');
     $template->assign('action', $this->is_test ? 1024 : 1);
     $template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
     $template->assign('is_monetary', 1);
     $template->assign('is_recur', (bool) $recur);
     $template->assign('currency', $this->currency);
     $template->assign('address', CRM_Utils_Address::format($input));
     if (!empty($values['customGroup'])) {
         $template->assign('customGroup', $values['customGroup']);
     }
     if ($this->_component == 'event') {
         $template->assign('title', $values['event']['title']);
         $participantRoles = CRM_Event_PseudoConstant::participantRole();
         $viewRoles = array();
         foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
             $viewRoles[] = $participantRoles[$v];
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例9: array_merge

 /**
  * Replace all the org-level tokens in $str
  *
  * @param string $str
  *   The string with tokens to be replaced.
  * @param object $org
  *   Associative array of org properties.
  * @param bool $html
  *   Replace tokens with HTML or plain text.
  *
  * @param bool $escapeSmarty
  *
  * @return string
  *   The processed string
  */
 public static function &replaceOrgTokens($str, &$org, $html = FALSE, $escapeSmarty = FALSE)
 {
     self::$_tokens['org'] = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields('Organization')), array('address', 'display_name', 'checksum', 'contact_id'));
     $cv = NULL;
     foreach (self::$_tokens['org'] as $token) {
         // print "Getting token value for $token<br/><br/>";
         if ($token == '') {
             continue;
         }
         // If the string doesn't contain this token, skip it.
         if (!self::token_match('org', $token, $str)) {
             continue;
         }
         // Construct value from $token and $contact
         $value = NULL;
         if ($cfID = CRM_Core_BAO_CustomField::getKeyID($token)) {
             // only generate cv if we need it
             if ($cv === NULL) {
                 $cv = CRM_Core_BAO_CustomValue::getContactValues($org['contact_id']);
             }
             foreach ($cv as $cvFieldID => $value) {
                 if ($cvFieldID == $cfID) {
                     $value = CRM_Core_BAO_CustomOption::getOptionLabel($cfID, $value);
                     break;
                 }
             }
         } elseif ($token == 'checksum') {
             $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($org['contact_id']);
             $value = "cs={$cs}";
         } elseif ($token == 'address') {
             // Build the location values array
             $loc = array();
             $loc['display_name'] = CRM_Utils_Array::retrieveValueRecursive($org, 'display_name');
             $loc['street_address'] = CRM_Utils_Array::retrieveValueRecursive($org, 'street_address');
             $loc['city'] = CRM_Utils_Array::retrieveValueRecursive($org, 'city');
             $loc['state_province'] = CRM_Utils_Array::retrieveValueRecursive($org, 'state_province');
             $loc['postal_code'] = CRM_Utils_Array::retrieveValueRecursive($org, 'postal_code');
             // Construct the address token
             $value = CRM_Utils_Address::format($loc);
             if ($html) {
                 $value = str_replace("\n", '<br />', $value);
             }
         } else {
             $value = CRM_Utils_Array::retrieveValueRecursive($org, $token);
         }
         self::token_replace('org', $token, $value, $str, $escapeSmarty);
     }
     return $str;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:64,代码来源:Token.php

示例10: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     $fv = $this->controller->exportValues($this->_name);
     $config = CRM_Core_Config::singleton();
     $locName = NULL;
     //get the address format sequence from the config file
     $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     $sequence = CRM_Utils_Address::sequence($mailingFormat);
     foreach ($sequence as $v) {
         $address[$v] = 1;
     }
     if (array_key_exists('postal_code', $address)) {
         $address['postal_code_suffix'] = 1;
     }
     //build the returnproperties
     $returnProperties = array('display_name' => 1, 'contact_type' => 1);
     $mailingFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     $mailingFormatProperties = array();
     if ($mailingFormat) {
         $mailingFormatProperties = self::getReturnProperties($mailingFormat);
         $returnProperties = array_merge($returnProperties, $mailingFormatProperties);
     }
     //we should not consider addressee for data exists, CRM-6025
     if (array_key_exists('addressee', $mailingFormatProperties)) {
         unset($mailingFormatProperties['addressee']);
     }
     $customFormatProperties = array();
     if (stristr($mailingFormat, 'custom_')) {
         foreach ($mailingFormatProperties as $token => $true) {
             if (substr($token, 0, 7) == 'custom_') {
                 if (empty($customFormatProperties[$token])) {
                     $customFormatProperties[$token] = $mailingFormatProperties[$token];
                 }
             }
         }
     }
     if (!empty($customFormatProperties)) {
         $returnProperties = array_merge($returnProperties, $customFormatProperties);
     }
     if (isset($fv['merge_same_address'])) {
         // we need first name/last name for summarising to avoid spillage
         $returnProperties['first_name'] = 1;
         $returnProperties['last_name'] = 1;
     }
     $individualFormat = FALSE;
     /*
      * CRM-8338: replace ids of household members with the id of their household
      * so we can merge labels by household.
      */
     if (isset($fv['merge_same_household'])) {
         $this->mergeContactIdsByHousehold();
         $individualFormat = TRUE;
     }
     //get the contacts information
     $params = array();
     if (!empty($fv['location_type_id'])) {
         $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
         $locName = $locType[$fv['location_type_id']];
         $location = array('location' => array("{$locName}" => $address));
         $returnProperties = array_merge($returnProperties, $location);
         $params[] = array('location_type', '=', array($fv['location_type_id'] => 1), 0, 0);
     } else {
         $returnProperties = array_merge($returnProperties, $address);
     }
     $rows = array();
     foreach ($this->_contactIds as $key => $contactID) {
         $params[] = array(CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0);
     }
     // fix for CRM-2651
     if (!empty($fv['do_not_mail'])) {
         $params[] = array('do_not_mail', '=', 0, 0, 0);
     }
     // fix for CRM-2613
     $params[] = array('is_deceased', '=', 0, 0, 0);
     $custom = array();
     foreach ($returnProperties as $name => $dontCare) {
         $cfID = CRM_Core_BAO_CustomField::getKeyID($name);
         if ($cfID) {
             $custom[] = $cfID;
         }
     }
     //get the total number of contacts to fetch from database.
     $numberofContacts = count($this->_contactIds);
     $query = new CRM_Contact_BAO_Query($params, $returnProperties);
     $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
     $messageToken = CRM_Utils_Token::getTokens($mailingFormat);
     // also get all token values
     CRM_Utils_Hook::tokenValues($details[0], $this->_contactIds, NULL, $messageToken, 'CRM_Contact_Form_Task_Label');
     $tokens = array();
     CRM_Utils_Hook::tokens($tokens);
     $tokenFields = array();
     foreach ($tokens as $category => $catTokens) {
         foreach ($catTokens as $token => $tokenName) {
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Label.php

示例11: date

 /**
  * function to get the complete information for one or more events
  *
  * @param  date    $start    get events with start date >= this date
  * @param  integer $type     get events on the a specific event type (by event_type_id) 
  * @param  integer $eventId  return a single event - by event id 
  * @param  date    $end      also get events with end date >= this date
  *
  * @return  array  $all      array of all the events that are searched
  * @static
  * @access public
  */
 static function &getCompleteInfo($start = null, $type = null, $eventId = null, $end = null)
 {
     // if start and end date are NOT passed, return all events with start_date OR end_date >= today CRM-5133
     if ($start) {
         // get events with start_date >= requested start
         $startDate = CRM_Utils_Type::escape($start, 'Date');
     } else {
         // get events with start date >= today
         $startDate = date("Ymd");
     }
     if ($end) {
         // also get events with end_date >= requested end
         $endDate = CRM_Utils_Type::escape($end, 'Date');
     } else {
         // OR also get events with end date >= today
         $endDate = date("Ymd");
     }
     $dateCondition = "AND (civicrm_event.start_date >= {$startDate} OR civicrm_event.end_date >= {$endDate})";
     if ($type) {
         $typeCondition = " AND civicrm_event.event_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
     }
     // Get the Id of Option Group for Event Types
     require_once 'CRM/Core/DAO/OptionGroup.php';
     $optionGroupDAO = new CRM_Core_DAO_OptionGroup();
     $optionGroupDAO->name = 'event_type';
     $optionGroupId = null;
     if ($optionGroupDAO->find(true)) {
         $optionGroupId = $optionGroupDAO->id;
     }
     $query = "\nSELECT\n  civicrm_event.id as event_id, \n  civicrm_email.email as email, \n  civicrm_event.title as title, \n  civicrm_event.summary as summary, \n  civicrm_event.start_date as start, \n  civicrm_event.end_date as end, \n  civicrm_event.description as description, \n  civicrm_event.is_show_location as is_show_location, \n  civicrm_event.is_online_registration as is_online_registration,\n  civicrm_event.registration_link_text as registration_link_text,\n  civicrm_event.registration_start_date as registration_start_date,\n  civicrm_event.registration_end_date as registration_end_date,\n  civicrm_option_value.label as event_type, \n  civicrm_address.name as address_name, \n  civicrm_address.street_address as street_address, \n  civicrm_address.supplemental_address_1 as supplemental_address_1, \n  civicrm_address.supplemental_address_2 as supplemental_address_2, \n  civicrm_address.city as city, \n  civicrm_address.postal_code as postal_code, \n  civicrm_address.postal_code_suffix as postal_code_suffix, \n  civicrm_state_province.abbreviation as state, \n  civicrm_country.name AS country\nFROM civicrm_event\nLEFT JOIN civicrm_loc_block ON civicrm_event.loc_block_id = civicrm_loc_block.id\nLEFT JOIN civicrm_address ON civicrm_loc_block.address_id = civicrm_address.id\nLEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id\nLEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id\nLEFT JOIN civicrm_email ON civicrm_loc_block.email_id = civicrm_email.id\nLEFT JOIN civicrm_option_value ON (\n                                    civicrm_event.event_type_id = civicrm_option_value.value AND\n                                    civicrm_option_value.option_group_id = %1 )\nWHERE civicrm_event.is_active = 1 \n      AND civicrm_event.is_public = 1\n      AND (is_template = 0 OR is_template IS NULL)\n      {$dateCondition}";
     if (isset($typeCondition)) {
         $query .= $typeCondition;
     }
     if (isset($eventId)) {
         $query .= " AND civicrm_event.id ={$eventId} ";
     }
     $query .= " ORDER BY   civicrm_event.start_date ASC";
     $params = array(1 => array($optionGroupId, 'Integer'));
     $dao =& CRM_Core_DAO::executeQuery($query, $params);
     $all = array();
     $config = CRM_Core_Config::singleton();
     $baseURL = parse_url($config->userFrameworkBaseURL);
     $url = "@" . $baseURL['host'];
     if (CRM_Utils_Array::value('path', $baseURL)) {
         $url .= substr($baseURL['path'], 0, -1);
     }
     // check 'view event info' permission
     $permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
     require_once 'CRM/Utils/String.php';
     while ($dao->fetch()) {
         if (in_array($dao->event_id, $permissions)) {
             $info = array();
             $info['uid'] = "CiviCRM_EventID_{$dao->event_id}_" . md5($config->userFrameworkBaseURL) . $url;
             $info['title'] = $dao->title;
             $info['event_id'] = $dao->event_id;
             $info['summary'] = $dao->summary;
             $info['description'] = $dao->description;
             $info['start_date'] = $dao->start;
             $info['end_date'] = $dao->end;
             $info['contact_email'] = $dao->email;
             $info['event_type'] = $dao->event_type;
             $info['is_show_location'] = $dao->is_show_location;
             $info['is_online_registration'] = $dao->is_online_registration;
             $info['registration_link_text'] = $dao->registration_link_text;
             $info['registration_start_date'] = $dao->registration_start_date;
             $info['registration_end_date'] = $dao->registration_end_date;
             $address = '';
             $addrFields = array('address_name' => $dao->address_name, 'street_address' => $dao->street_address, 'supplemental_address_1' => $dao->supplemental_address_1, 'supplemental_address_2' => $dao->supplemental_address_2, 'city' => $dao->city, 'state_province' => $dao->state, 'postal_code' => $dao->postal_code, 'postal_code_suffix' => $dao->postal_code_suffix, 'country' => $dao->country, 'county' => null);
             require_once 'CRM/Utils/Address.php';
             CRM_Utils_String::append($address, ', ', CRM_Utils_Address::format($addrFields));
             $info['location'] = $address;
             $info['url'] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, true, null, false);
             $all[] = $info;
         }
     }
     return $all;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:89,代码来源:Event.php

示例12: postProcess


//.........这里部分代码省略.........
         }
         //assign contribution contact id to the field expected by recordMembershipContribution
         if ($this->_contributorContactID != $this->_contactID) {
             $formValues['contribution_contact_id'] = $this->_contributorContactID;
             if (!empty($this->_params['soft_credit_type_id'])) {
                 $formValues['soft_credit'] = array('soft_credit_type_id' => $this->_params['soft_credit_type_id'], 'contact_id' => $this->_contactID);
             }
         }
         $formValues['contact_id'] = $this->_contactID;
         //recordMembershipContribution receives params as a reference & adds one variable. This is
         // not a great pattern & ideally it would not receive as a reference. We assign our params as a
         // temporary variable to avoid e-notice & to make it clear to future refactorer that
         // this function is NOT reliant on that var being set
         $temporaryParams = array_merge($formValues, array('membership_id' => $renewMembership->id));
         CRM_Member_BAO_Membership::recordMembershipContribution($temporaryParams);
     }
     $receiptSend = FALSE;
     if (!empty($formValues['send_receipt'])) {
         $receiptSend = TRUE;
         $receiptFrom = $formValues['from_email_address'];
         if (!empty($formValues['payment_instrument_id'])) {
             $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
             $formValues['paidBy'] = $paymentInstrument[$formValues['payment_instrument_id']];
         }
         //get the group Tree
         $this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', $this, $this->_id, FALSE, $this->_memType);
         // retrieve custom data
         $customFields = $customValues = $fo = array();
         foreach ($this->_groupTree as $groupID => $group) {
             if ($groupID == 'info') {
                 continue;
             }
             foreach ($group['fields'] as $k => $field) {
                 $field['title'] = $field['label'];
                 $customFields["custom_{$k}"] = $field;
             }
         }
         $members = array(array('member_id', '=', $this->_membershipId, 0, 0));
         // check whether its a test drive
         if ($this->_mode == 'test') {
             $members[] = array('member_test', '=', 1, 0, 0);
         }
         CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members);
         $this->assign_by_ref('formValues', $formValues);
         if (!empty($formValues['contribution_id'])) {
             $this->assign('contributionID', $formValues['contribution_id']);
         }
         $this->assign('membershipID', $this->_id);
         $this->assign('contactID', $this->_contactID);
         $this->assign('module', 'Membership');
         $this->assign('receiptType', 'membership renewal');
         $this->assign('mem_start_date', CRM_Utils_Date::customFormat($renewMembership->start_date));
         $this->assign('mem_end_date', CRM_Utils_Date::customFormat($renewMembership->end_date));
         $this->assign('membership_name', CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id));
         $this->assign('customValues', $customValues);
         if ($this->_mode) {
             if (!empty($this->_params['billing_first_name'])) {
                 $name = $this->_params['billing_first_name'];
             }
             if (!empty($this->_params['billing_middle_name'])) {
                 $name .= " {$this->_params['billing_middle_name']}";
             }
             if (!empty($this->_params['billing_last_name'])) {
                 $name .= " {$this->_params['billing_last_name']}";
             }
             $this->assign('billingName', $name);
             // assign the address formatted up for display
             $addressParts = array("street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "state_province-{$this->_bltID}", "country-{$this->_bltID}");
             $addressFields = array();
             foreach ($addressParts as $part) {
                 list($n, $id) = explode('-', $part);
                 if (isset($this->_params['billing_' . $part])) {
                     $addressFields[$n] = $this->_params['billing_' . $part];
                 }
             }
             $this->assign('address', CRM_Utils_Address::format($addressFields));
             $date = CRM_Utils_Date::format($this->_params['credit_card_exp_date']);
             $date = CRM_Utils_Date::mysqlToIso($date);
             $this->assign('credit_card_exp_date', $date);
             $this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($this->_params['credit_card_number']));
             $this->assign('credit_card_type', $this->_params['credit_card_type']);
             $this->assign('contributeMode', 'direct');
             $this->assign('isAmountzero', 0);
             $this->assign('is_pay_later', 0);
             $this->assign('isPrimary', 1);
             if ($this->_mode == 'test') {
                 $this->assign('action', '1024');
             }
         }
         list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $this->_receiptContactId, 'from' => $receiptFrom, 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => $this->_mode == 'test'));
     }
     $statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $memType, 2 => $this->_memberDisplayName));
     if ($endDate) {
         $statusMsg .= ' ' . ts('The new membership End Date is %1.', array(1 => CRM_Utils_Date::customFormat(substr($endDate, 0, 8))));
     }
     if ($receiptSend && $mailSend) {
         $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
     }
     CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
 }
开发者ID:vincent1892,项目名称:contact_report,代码行数:101,代码来源:MembershipRenewal.php

示例13: sendMailings

    /**
     * @param $mappingID
     * @param $now
     *
     * @throws CRM_Core_Exception
     */
    static function sendMailings($mappingID, $now)
    {
        $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
        $fromEmailAddress = "{$domainValues['0']} <{$domainValues['1']}>";
        $mapping = new CRM_Core_DAO_ActionMapping();
        $mapping->id = $mappingID;
        $mapping->find(TRUE);
        $actionSchedule = new CRM_Core_DAO_ActionSchedule();
        $actionSchedule->mapping_id = $mappingID;
        $actionSchedule->is_active = 1;
        $actionSchedule->find(FALSE);
        $tokenFields = array();
        $session = CRM_Core_Session::singleton();
        while ($actionSchedule->fetch()) {
            $extraSelect = $extraJoin = $extraWhere = $extraOn = '';
            if ($actionSchedule->from_email) {
                $fromEmailAddress = "{$actionSchedule->from_name} <{$actionSchedule->from_email}>";
            }
            if ($actionSchedule->record_activity) {
                if ($mapping->entity == 'civicrm_membership') {
                    $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name');
                } else {
                    $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Reminder Sent', 'name');
                }
                $activityStatusID = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
            }
            if ($mapping->entity == 'civicrm_activity') {
                $tokenEntity = 'activity';
                $tokenFields = array('activity_id', 'activity_type', 'subject', 'details', 'activity_date_time');
                $extraSelect = ', ov.label as activity_type, e.id as activity_id';
                $extraJoin = "\nINNER JOIN civicrm_option_group og ON og.name = 'activity_type'\nINNER JOIN civicrm_option_value ov ON e.activity_type_id = ov.value AND ov.option_group_id = og.id";
                $extraOn = ' AND e.is_current_revision = 1 AND e.is_deleted = 0 ';
                if ($actionSchedule->limit_to == 0) {
                    $extraJoin = "\nLEFT JOIN civicrm_option_group og ON og.name = 'activity_type'\nLEFT JOIN civicrm_option_value ov ON e.activity_type_id = ov.value AND ov.option_group_id = og.id";
                }
            }
            if ($mapping->entity == 'civicrm_participant') {
                $tokenEntity = 'event';
                $tokenFields = array('event_type', 'title', 'event_id', 'start_date', 'end_date', 'summary', 'description', 'location', 'info_url', 'registration_url', 'fee_amount', 'contact_email', 'contact_phone', 'balance');
                $extraSelect = ', ov.label as event_type, ev.title, ev.id as event_id, ev.start_date, ev.end_date, ev.summary, ev.description, address.street_address, address.city, address.state_province_id, address.postal_code, email.email as contact_email, phone.phone as contact_phone ';
                $extraJoin = "\nINNER JOIN civicrm_event ev ON e.event_id = ev.id\nINNER JOIN civicrm_option_group og ON og.name = 'event_type'\nINNER JOIN civicrm_option_value ov ON ev.event_type_id = ov.value AND ov.option_group_id = og.id\nLEFT  JOIN civicrm_loc_block lb ON lb.id = ev.loc_block_id\nLEFT  JOIN civicrm_address address ON address.id = lb.address_id\nLEFT  JOIN civicrm_email email ON email.id = lb.email_id\nLEFT  JOIN civicrm_phone phone ON phone.id = lb.phone_id\n";
                if ($actionSchedule->limit_to == 0) {
                    $extraJoin = "\nLEFT JOIN civicrm_event ev ON e.event_id = ev.id\nLEFT JOIN civicrm_option_group og ON og.name = 'event_type'\nLEFT JOIN civicrm_option_value ov ON ev.event_type_id = ov.value AND ov.option_group_id = og.id\nLEFT JOIN civicrm_loc_block lb ON lb.id = ev.loc_block_id\nLEFT JOIN civicrm_address address ON address.id = lb.address_id\nLEFT JOIN civicrm_email email ON email.id = lb.email_id\nLEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id\n";
                }
            }
            if ($mapping->entity == 'civicrm_membership') {
                $tokenEntity = 'membership';
                $tokenFields = array('fee', 'id', 'join_date', 'start_date', 'end_date', 'status', 'type');
                $extraSelect = ', mt.minimum_fee as fee, e.id as id , e.join_date, e.start_date, e.end_date, ms.name as status, mt.name as type';
                $extraJoin = '
 INNER JOIN civicrm_membership_type mt ON e.membership_type_id = mt.id
 INNER JOIN civicrm_membership_status ms ON e.status_id = ms.id';
                if ($actionSchedule->limit_to == 0) {
                    $extraJoin = '
 LEFT JOIN civicrm_membership_type mt ON e.membership_type_id = mt.id
 LEFT JOIN civicrm_membership_status ms ON e.status_id = ms.id';
                }
            }
            if ($mapping->entity == 'civicrm_contact') {
                $tokenEntity = 'contact';
                //TODO: get full list somewhere!
                $tokenFields = array('birth_date', 'last_name');
                //TODO: is there anything to add here?
            }
            $entityJoinClause = "INNER JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
            if ($actionSchedule->limit_to == 0) {
                $entityJoinClause = "LEFT JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
                $extraWhere .= " AND (e.id = reminder.entity_id OR reminder.entity_table = 'civicrm_contact')";
            }
            $entityJoinClause .= $extraOn;
            $query = "\nSELECT reminder.id as reminderID, reminder.contact_id as contactID, reminder.*, e.id as entityID, e.* {$extraSelect}\nFROM  civicrm_action_log reminder\n{$entityJoinClause}\n{$extraJoin}\nWHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL\n{$extraWhere}";
            $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
            while ($dao->fetch()) {
                $entityTokenParams = array();
                foreach ($tokenFields as $field) {
                    if ($field == 'location') {
                        $loc = array();
                        $stateProvince = CRM_Core_PseudoConstant::stateProvince();
                        $loc['street_address'] = $dao->street_address;
                        $loc['city'] = $dao->city;
                        $loc['state_province'] = CRM_Utils_Array::value($dao->state_province_id, $stateProvince);
                        $loc['postal_code'] = $dao->postal_code;
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Address::format($loc);
                    } elseif ($field == 'info_url') {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE);
                    } elseif ($field == 'registration_url') {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE);
                    } elseif (in_array($field, array('start_date', 'end_date', 'join_date', 'activity_date_time'))) {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->{$field});
                    } elseif ($field == 'balance') {
                        $info = CRM_Contribute_BAO_Contribution::getPaymentInfo($dao->entityID, 'event');
                        $balancePay = CRM_Utils_Array::value('balance', $info);
                        $balancePay = CRM_Utils_Money::format($balancePay);
                        $entityTokenParams["{$tokenEntity}." . $field] = $balancePay;
//.........这里部分代码省略.........
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:101,代码来源:ActionSchedule.php

示例14: postProcess

 /**
  * Process the form after the input has been submitted and validated.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $formValues = $this->controller->exportValues($this->_name);
     $locationTypeID = $formValues['location_type_id'];
     $respectDoNotMail = CRM_Utils_Array::value('do_not_mail', $formValues);
     $labelName = $formValues['label_name'];
     $mergeSameAddress = CRM_Utils_Array::value('merge_same_address', $formValues);
     $mergeSameHousehold = CRM_Utils_Array::value('merge_same_household', $formValues);
     $isPerMembership = CRM_Utils_Array::value('per_membership', $formValues);
     if ($isPerMembership && ($mergeSameAddress || $mergeSameHousehold)) {
         // this shouldn't happen  - perhaps is could if JS is disabled
         CRM_Core_Session::setStatus(ts('As you are printing one label per membership your merge settings are being ignored'));
         $mergeSameAddress = $mergeSameHousehold = FALSE;
     }
     // so no-one is tempted to refer to this again after relevant values are extracted
     unset($formValues);
     list($rows, $tokenFields) = CRM_Contact_Form_Task_LabelCommon::getRows($this->_contactIds, $locationTypeID, $respectDoNotMail, $mergeSameAddress, $mergeSameHousehold);
     $individualFormat = FALSE;
     if ($mergeSameAddress) {
         CRM_Core_BAO_Address::mergeSameAddress($rows);
         $individualFormat = TRUE;
     }
     if ($mergeSameHousehold) {
         $rows = CRM_Contact_Form_Task_LabelCommon::mergeSameHousehold($rows);
         $individualFormat = TRUE;
     }
     // format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
     foreach ((array) $rows as $id => $row) {
         if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) {
             $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods));
             $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
             $temp = array();
             foreach ($val as $vals) {
                 $temp[] = $comm[$vals];
             }
             $row['preferred_communication_method'] = implode(', ', $temp);
         }
         $row['id'] = $id;
         $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $individualFormat, $tokenFields);
         $rows[$id] = array($formatted);
     }
     if ($isPerMembership) {
         $labelRows = array();
         $memberships = civicrm_api3('membership', 'get', array('id' => array('IN' => $this->_memberIds), 'return' => 'contact_id'));
         foreach ($memberships['values'] as $id => $membership) {
             if (isset($rows[$membership['contact_id']])) {
                 $labelRows[$id] = $rows[$membership['contact_id']];
             }
         }
     } else {
         $labelRows = $rows;
     }
     //call function to create labels
     CRM_Contact_Form_Task_LabelCommon::createLabel($labelRows, $labelName);
     CRM_Utils_System::civiExit(1);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:62,代码来源:Label.php

示例15: emailReceipt

 /**
  * Send email receipt.
  *
  * @param CRM_Core_Form $form
  *   instance of Contribution form.
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param bool $ccContribution
  *   is it credit card contribution.
  *
  * @return array
  */
 public static function emailReceipt(&$form, &$params, $ccContribution = FALSE)
 {
     $form->assign('receiptType', 'contribution');
     // Retrieve Financial Type Name from financial_type_id
     $params['contributionType_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $params['financial_type_id']);
     if (!empty($params['payment_instrument_id'])) {
         $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
         $params['paidBy'] = $paymentInstrument[$params['payment_instrument_id']];
         if ($params['paidBy'] != 'Check' && isset($params['check_number'])) {
             unset($params['check_number']);
         }
     }
     // retrieve individual prefix value for honoree
     if (isset($params['soft_credit'])) {
         $softCreditTypes = $softCredits = array();
         foreach ($params['soft_credit'] as $key => $softCredit) {
             $softCredits[$key] = array('Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']));
             $softCreditTypes[$key] = $softCredit['soft_credit_type_label'];
         }
         $form->assign('softCreditTypes', $softCreditTypes);
         $form->assign('softCredits', $softCredits);
     }
     // retrieve premium product name and assigned fulfilled
     // date to template
     if (!empty($params['hidden_Premium'])) {
         if (isset($params['product_name']) && is_array($params['product_name']) && !empty($params['product_name'])) {
             $productDAO = new CRM_Contribute_DAO_Product();
             $productDAO->id = $params['product_name'][0];
             $productOptionID = $params['product_name'][1];
             $productDAO->find(TRUE);
             $params['product_name'] = $productDAO->name;
             $params['product_sku'] = $productDAO->sku;
             if (empty($params['product_option']) && !empty($form->_options[$productDAO->id])) {
                 $params['product_option'] = $form->_options[$productDAO->id][$productOptionID];
             }
         }
         if (!empty($params['fulfilled_date'])) {
             $form->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date']));
         }
     }
     $form->assign('ccContribution', $ccContribution);
     if ($ccContribution) {
         //build the name.
         $name = CRM_Utils_Array::value('billing_first_name', $params);
         if (!empty($params['billing_middle_name'])) {
             $name .= " {$params['billing_middle_name']}";
         }
         $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params);
         $name = trim($name);
         $form->assign('billingName', $name);
         //assign the address formatted up for display
         $addressParts = array("street_address" => "billing_street_address-{$form->_bltID}", "city" => "billing_city-{$form->_bltID}", "postal_code" => "billing_postal_code-{$form->_bltID}", "state_province" => "state_province-{$form->_bltID}", "country" => "country-{$form->_bltID}");
         $addressFields = array();
         foreach ($addressParts as $name => $field) {
             $addressFields[$name] = CRM_Utils_Array::value($field, $params);
         }
         $form->assign('address', CRM_Utils_Address::format($addressFields));
         $date = CRM_Utils_Date::format($params['credit_card_exp_date']);
         $date = CRM_Utils_Date::mysqlToIso($date);
         $form->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
         $form->assign('credit_card_exp_date', $date);
         $form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
     } else {
         //offline contribution
         // assigned various dates to the templates
         $form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date']));
         if (!empty($params['cancel_date'])) {
             $form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date']));
         }
         if (!empty($params['thankyou_date'])) {
             $form->assign('thankyou_date', CRM_Utils_Date::processDate($params['thankyou_date']));
         }
         if ($form->_action & CRM_Core_Action::UPDATE) {
             $form->assign('lineItem', empty($form->_lineItems) ? FALSE : $form->_lineItems);
         }
     }
     //handle custom data
     if (!empty($params['hidden_custom'])) {
         $contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0));
         if ($form->_mode == 'test') {
             $contribParams[] = array('contribution_test', '=', 1, 0, 0);
         }
         //retrieve custom data
         $customGroup = array();
         foreach ($form->_groupTree as $groupID => $group) {
             $customFields = $customValues = array();
             if ($groupID == 'info') {
                 continue;
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:AdditionalInfo.php


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