Esempio n. 1
0
 /**
  * @param $events_in_cart
  * @param array $params
  */
 public function emailReceipt($events_in_cart, $params)
 {
     $contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
     $state_province = new CRM_Core_DAO_StateProvince();
     $state_province->id = $params["billing_state_province_id-{$this->_bltID}"];
     $state_province->find();
     $state_province->fetch();
     $country = new CRM_Core_DAO_Country();
     $country->id = $params["billing_country_id-{$this->_bltID}"];
     $country->find();
     $country->fetch();
     foreach ($this->line_items as &$line_item) {
         $location_params = array('entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event');
         $line_item['location'] = CRM_Core_BAO_Location::getValues($location_params, TRUE);
         CRM_Core_BAO_Address::fixAddress($line_item['location']['address'][1]);
     }
     $send_template_params = array('table' => 'civicrm_msg_template', 'contactId' => $this->payer_contact_id, 'from' => $this->getDefaultFrom(), 'groupName' => 'msg_tpl_workflow_event', 'isTest' => FALSE, 'toEmail' => $contact_details[1], 'toName' => $contact_details[0], 'tplParams' => array('billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}", 'billing_city' => $params["billing_city-{$this->_bltID}"], 'billing_country' => $country->name, 'billing_postal_code' => $params["billing_postal_code-{$this->_bltID}"], 'billing_state' => $state_province->abbreviation, 'billing_street_address' => $params["billing_street_address-{$this->_bltID}"], 'credit_card_exp_date' => $params['credit_card_exp_date'], 'credit_card_type' => $params['credit_card_type'], 'credit_card_number' => "************" . substr($params['credit_card_number'], -4, 4), 'discounts' => $this->discounts, 'email' => $contact_details[1], 'events_in_cart' => $events_in_cart, 'line_items' => $this->line_items, 'name' => $contact_details[0], 'transaction_id' => $params['trxn_id'], 'transaction_date' => $params['trxn_date'], 'is_pay_later' => $this->is_pay_later, 'pay_later_receipt' => $this->pay_later_receipt), 'valueName' => 'event_registration_receipt', 'PDFFilename' => ts('confirmation') . '.pdf');
     $template_params_to_copy = array('billing_name', 'billing_city', 'billing_country', 'billing_postal_code', 'billing_state', 'billing_street_address', 'credit_card_exp_date', 'credit_card_type', 'credit_card_number');
     foreach ($template_params_to_copy as $template_param_to_copy) {
         $this->set($template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]);
     }
     CRM_Core_BAO_MessageTemplate::sendTemplate($send_template_params);
 }