/** * Send receipt from contribution. * * @deprecated * * Note that the compose message part has been moved to contribution * In general LoadObjects is called first to get the objects but the composeMessageArray function now calls it * * @param array $input * Incoming data from Payment processor. * @param array $ids * Related object IDs. * @param array $objects * @param array $values * Values related to objects that have already been loaded. * @param bool $recur * Is it part of a recurring contribution. * @param bool $returnMessageText * Should text be returned instead of sent. This. * is because the function is also used to generate pdfs * * @return array */ public function sendMail(&$input, &$ids, &$objects, &$values, $recur = FALSE, $returnMessageText = FALSE) { return CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution'], $values, $recur, $returnMessageText); }
/** * Process the form after the input has been submitted and validated. */ public function postProcess() { // get all the details needed to generate a receipt $message = array(); $template = CRM_Core_Smarty::singleton(); $params = $this->controller->exportValues($this->_name); $elements = self::getElements($this->_contributionIds, $params, $this->_contactIds); foreach ($elements['details'] as $contribID => $detail) { $input = $ids = $objects = array(); if (in_array($detail['contact'], $elements['excludeContactIds'])) { continue; } $input['component'] = $detail['component']; $ids['contact'] = $detail['contact']; $ids['contribution'] = $contribID; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; $ids['membership'] = CRM_Utils_Array::value('membership', $detail); $ids['participant'] = CRM_Utils_Array::value('participant', $detail); $ids['event'] = CRM_Utils_Array::value('event', $detail); if (!$elements['baseIPN']->validateData($input, $ids, $objects, FALSE)) { CRM_Core_Error::fatal(); } $contribution =& $objects['contribution']; // set some fake input values so we can reuse IPN code $input['amount'] = $contribution->total_amount; $input['is_test'] = $contribution->is_test; $input['fee_amount'] = $contribution->fee_amount; $input['net_amount'] = $contribution->net_amount; $input['trxn_id'] = $contribution->trxn_id; $input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : NULL; $input['receipt_update'] = $params['receipt_update']; $input['contribution_status_id'] = $contribution->contribution_status_id; // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); $values = array(); $mail = CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution'], $values, FALSE, $elements['createPdf']); if ($mail['html']) { $message[] = $mail['html']; } else { $message[] = nl2br($mail['body']); } // reset template values before processing next transactions $template->clearTemplateVars(); } if ($elements['createPdf']) { CRM_Utils_PDF_Utils::html2pdf($message, 'civicrmContributionReceipt.pdf', FALSE, $elements['params']['pdf_format_id']); CRM_Utils_System::civiExit(); } else { if ($elements['suppressedEmails']) { $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $elements['suppressedEmails'])); $msgTitle = ts('Email Error'); $msgType = 'error'; } else { $status = ts('Your mail has been sent.'); $msgTitle = ts('Sent'); $msgType = 'success'; } CRM_Core_Session::setStatus($status, $msgTitle, $msgType); } }
/** * Send a contribution confirmation (receipt or invoice). * * The appropriate online template will be used (the existence of related objects * (e.g. memberships ) will affect this selection * * @param array $params * Input parameters. * * @throws Exception */ function civicrm_api3_contribution_sendconfirmation($params) { $input = $ids = $values = array(); $passThroughParams = array('receipt_from_email', 'receipt_from_name', 'receipt_update', 'cc_receipt', 'bcc_receipt', 'receipt_text', 'payment_processor_id'); foreach ($passThroughParams as $key) { if (isset($params[$key])) { $input[$key] = $params[$key]; } } CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $params['id'], $values); }