class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_ContributionPage {
/**
- * takes an associative array and creates a contribution page object
+ * Takes an associative array and creates a contribution page object
*
* @param array $params (reference ) an assoc array of name/value pairs
*
- * @return object CRM_Contribute_DAO_ContributionPage object
+ * @return CRM_Contribute_DAO_ContributionPage object
* @access public
* @static
*/
if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
}
+ $hook = empty($params['id']) ? 'create' : 'edit';
+ CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params);
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->copyValues($params);
$dao->save();
if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
}
+ CRM_Utils_Hook::post($hook, 'ContributionPage', $dao->id, $dao);
return $dao;
}
/**
- * update the is_active flag in the db
+ * Update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
}
/**
- * @param $id
+ * @param int $id
* @param $values
*/
static function setValues($id, &$values) {
}
/**
- * Function to send the emails
+ * Send the emails
*
* @param int $contactID contact id
* @param array $values associated array of fields
'displayName' => $displayName,
'contributionID' => CRM_Utils_Array::value('contribution_id', $values),
'contributionOtherID' => CRM_Utils_Array::value('contribution_other_id', $values),
- 'membershipID' => CRM_Utils_Array::value('membership_id', $values),
// CRM-5095
'lineItem' => CRM_Utils_Array::value('lineItem', $values),
// CRM-5095
// use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not
$sendTemplateParams = array(
- 'groupName' => $tplParams['membershipID'] ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution',
- 'valueName' => $tplParams['membershipID'] ? 'membership_online_receipt' : 'contribution_online_receipt',
+ 'groupName' => !empty($values['isMembership']) ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution',
+ 'valueName' => !empty($values['isMembership']) ? 'membership_online_receipt' : 'contribution_online_receipt',
'contactId' => $contactID,
'tplParams' => $tplParams,
'isTest' => $isTest,
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values);
+ //send email with pdf invoice
+ $template = CRM_Core_Smarty::singleton( );
+ $taxAmt = $template->get_template_vars('dataArray');
+ $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+ $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
+ if (count($taxAmt) > 0 && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
+ $sendTemplateParams['isEmailPdf'] = True;
+ $sendTemplateParams['contributionId'] = $values['contribution_id'];
+ }
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
}
}
- /*
- * Construct the message to be sent by the send function
- *
- */
/**
- * @param $tplParams
- * @param $contactID
+ * Construct the message to be sent by the send function
+ *
+ * @param array $tplParams
+ * @param int $contactID
* @param $isTest
*
* @return array
}
/**
- * Function to send the emails for Recurring Contribution Notication
+ * Send the emails for Recurring Contribution Notication
*
* @param string $type txnType
* @param int $contactID contact id for contributor
}
/**
- * Function to add the custom fields for contribution page (ie profile)
+ * Add the custom fields for contribution page (ie profile)
*
* @param int $gid uf group id
* @param string $name
}
/**
- * Function to check if contribution page contains payment
+ * Check if contribution page contains payment
* processor that supports recurring payment
*
* @param int $contributionPageId Contribution Page Id
}
/**
- * Function to get info for all sections enable/disable.
+ * Get info for all sections enable/disable.
*
* @param array $contribPageIds
* @return array $info info regarding all sections.
return $sctJson;
}
+ /**
+ * Generate html for pdf in confirmation receipt email attachment
+ * @param int $contributionId Contribution Page Id
+ * @param int $userID contact id for contributor
+ * @return array $pdfHtml
+ */
+ static function addInvoicePdfToEmail($contributionId, $userID) {
+ $contributionID = array($contributionId);
+ $contactId = array($userID);
+ $pdfParams = array(
+ 'output' => 'pdf_invoice',
+ 'forPage' => 'confirmpage'
+ );
+ $pdfHtml = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID,
+ $pdfParams, $contactId, CRM_Core_DAO::$_nullObject);
+ return $pdfHtml;
+ }
/**
- * helper to determine if the page supports separate membership payments
+ * Helper to determine if the page supports separate membership payments
* @param integer id form id
*
* @return bool isSeparateMembershipPayment