*/
public static function pcpNotifyOwner($contribution, $contributionSoft) {
- $component = $contribution->_component ? $contribution->_component : 'contribute';
- $ownerNotifyID = CRM_PCP_BAO_PCP::getOwnerNotificationId($contributionSoft->pcp_id);
- if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') ||
- ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') &&
- CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify'))) {
- $pcpPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($contributionSoft->pcp_id, $component);
+ $params = array('id' => $contributionSoft->pcp_id);
+ CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
+ $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
+
+ if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') &&
+ (($ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') &&
+ CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify')) ||
+ $ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'all_owners', 'name'))) {
+ $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info',
+ "reset=1&id={$contributionSoft->pcp_id}",
+ TRUE, NULL, FALSE, TRUE
+ );
// set email in the template here
- $donorName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contribution->contact_id, 'display_name');
+ // get the billing location type
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
+ $billingLocationTypeId = array_search('Billing', $locationTypes);
+
+ if ($billingLocationTypeId) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, $billingLocationTypeId);
+ }
+ // get primary location email if no email exist( for billing location).
+ if (!$email) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id);
+ }
+ list($ownerName, $ownerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft->contact_id);
$tplParams = array(
- 'page_title' => $pcpPageTitle,
+ 'page_title' => $pcpInfo['title'],
'receive_date' => $contribution->receive_date,
'total_amount' => $contributionSoft->amount,
'donors_display_name' => $donorName,
- 'donors_email' => CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id),
+ 'donors_email' => $email,
+ 'pcpInfoURL' => $pcpInfoURL,
'is_honor_roll_enabled' => $contributionSoft->pcp_display_in_roll,
);
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
'groupName' => 'msg_tpl_workflow_contribution',
'valueName' => 'pcp_owner_notify',
'contactId' => $contributionSoft->contact_id,
- 'toEmail' => CRM_Contact_BAO_Contact::getPrimaryEmail($contributionSoft->contact_id),
- 'toName' => $donorName,
+ 'toEmail' => $ownerEmail,
+ 'toName' => $ownerName,
'from' => "$domainValues[0] <$domainValues[1]>",
'tplParams' => $tplParams,
'PDFFilename' => 'receipt.pdf',
*/
protected $_first = FALSE;
+ /**
+ * Is this the last page?
+ *
+ * @var boolean
+ */
+ protected $_last = FALSE;
+
/**
* Store price set id.
*
}
if ($this->_single) {
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => ts('Save'),
- 'spacing' => ' ',
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'upload',
- 'name' => ts('Save and Done'),
- 'spacing' => ' ',
- 'subName' => 'done',
- ),
- array(
- 'type' => 'submit',
- 'name' => ts('Save and Next'),
- 'spacing' => ' ',
- 'subName' => 'savenext',
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
+ $buttons = array(
+ array(
+ 'type' => 'next',
+ 'name' => ts('Save'),
+ 'spacing' => ' ',
+ 'isDefault' => TRUE,
+ ),
+ array(
+ 'type' => 'upload',
+ 'name' => ts('Save and Done'),
+ 'spacing' => ' ',
+ 'subName' => 'done',
+ ),
);
+ if (!$this->_last) {
+ $buttons[] = array(
+ 'type' => 'submit',
+ 'name' => ts('Save and Next'),
+ 'spacing' => ' ',
+ 'subName' => 'savenext',
+ );
+ }
+ $buttons[] = array(
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ );
+ $this->addButtons($buttons);
}
else {
$buttons = array();
//CRM-15821 - To add new option for PCP "Owner" notification
$ownerNotifications = CRM_Core_OptionGroup::values('pcp_owner_notify');
- $form->addRadio('owner_notify_id', ts('Owner Notification'), $ownerNotifications, NULL, NULL, TRUE);
+ $form->addRadio('owner_notify_id', ts('Owner Notification'), $ownerNotifications, NULL, '<br/>', TRUE);
$form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);"));
* @param CRM_Core_Page $page
* @param null $elements
*/
- public function buildPcp($pcpId, &$page, &$elements = NULL) {
+ public static function buildPcp($pcpId, &$page, &$elements = NULL) {
$prms = array('id' => $pcpId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) {
if ($pcpInfo['page_type'] == 'event') {
- $pcp_supporter_text = ts('This event registration is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
+ $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
if (!empty($text)) {
$pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
}
}
else {
- $pcp_supporter_text = ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
+ $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
$text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
if (!empty($text)) {
$pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
/**
* Get owner notification id
*
- * @param int $pcpId
+ * @param int $component_id
* @param $component
*
- *
* @return int
*/
- public static function getOwnerNotificationId($pcpId) {
+ public static function getOwnerNotificationId($component_id, $component = 'contribute') {
+ $entity_table = self::getPcpEntityTable($component);
$query = "
SELECT pb.owner_notify_id
FROM civicrm_pcp_block pb
- LEFT JOIN civicrm_pcp pcp ON ( pb.id = pcp.pcp_block_id )
- WHERE pcp.id = %1";
- $params = array(1 => array($pcpId, 'Integer'));
- return CRM_Core_DAO::singleValueQuery($query, $params);
+ WHERE pb.entity_id = %1 AND pb.entity_table = %2";
+ $params = array(1 => array($component_id, 'Integer'), 2 => array($entity_table, 'String'));
+ if (!$ownerNotificationId = CRM_Core_DAO::singleValueQuery($query, $params)) {
+ CRM_Core_Error::fatal(ts('Owner Notification is not set for this Personal Campaign Page. Please contact the site administrator if you need assistance.'));
+ }
+ else {
+ return $ownerNotificationId;
+ }
}
}
$this->addElement('checkbox', 'is_thermometer', ts('Progress Bar'));
$this->addElement('checkbox', 'is_honor_roll', ts('Honor Roll'), NULL);
-
- $owner_notification_option = $this->_pageId ? CRM_PCP_BAO_PCP::getOwnerNotificationId($this->_pageId) : CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $this->controller->get('component_page_id'), 'owner_notify_id');
+ if ($this->_pageId) {
+ $params = array('id' => $this->_pageId);
+ CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
+ $owner_notification_option = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
+ }
+ else {
+ $owner_notification_option = CRM_PCP_BAO_PCP::getOwnerNotificationId($this->controller->get('component_page_id'), $this->_component ? $this->_component : 'contribute');
+ }
if ($owner_notification_option == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name')) {
$this->assign('owner_notification_option', TRUE);
$this->addElement('checkbox', 'is_notify', ts('Notify me via email when someone donates to my page'), NULL);
* @return void
*/
public function buildQuickForm() {
+ $this->_last = TRUE;
CRM_PCP_BAO_PCP::buildPCPForm($this);
$this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this contribution page)'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);"));
{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
{capture assign=pcpURL }{crmURL p="civicrm/pcp/info" q="reset=1&id=`$pcpId`" h=0 a=1}{/capture}
- <p>{ts}You have received a donation at your personal page{/ts}: {$page_title}</p>
+ <p>{ts}You have received a donation at your personal page{/ts}: <a href="{$pcpInfoURL}">{$page_title}</a></p>
<p>{ts}Your fundraising total has been updated.{/ts}<br/>
{ts}The donor's information is listed below. You can choose to contact them and convey your thanks if you wish.{/ts} <br/>
{if $is_honor_roll_enabled}
===========================================================
{ts}You have received a donation at your personal page{/ts}: {$page_title}
+>> {$pcpInfoURL}
{ts}Your fundraising total has been updated.{/ts}
{ts}The donor's information is listed below. You can choose to contact them and convey your thanks if you wish.{/ts}
</tr>
<tr class="crm-contribution-contributionpage-pcp-form-block-owner_notify_id">
<td class="label">{$form.owner_notify_id.label}</td>
- <td>{$form.owner_notify_id.html} {help id="id-owner_notify"}</td>
+ <td>{$form.owner_notify_id.html}</td>
</tr>
<tr class="crm-contribution-contributionpage-pcp-form-block-is_tellfriend_enabled">
<td class="label">{$form.is_tellfriend_enabled.label}</td>
{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
{capture assign=pcpURL }{crmURL p="civicrm/pcp/info" q="reset=1&id=`$pcpId`" h=0 a=1}{/capture}
- <p>{ts}You have received a donation at your personal page{/ts}: {$page_title}</p>
+ <p>{ts}You have received a donation at your personal page{/ts}: <a href="{$pcpInfoURL}">{$page_title}</a></p>
<p>{ts}Your fundraising total has been updated.{/ts}<br/>
{ts}The donor's information is listed below. You can choose to contact them and convey your thanks if you wish.{/ts} <br/>
{if $is_honor_roll_enabled}
===========================================================
{ts}You have received a donation at your personal page{/ts}: {$page_title}
+>> {$pcpInfoURL}
{ts}Your fundraising total has been updated.{/ts}
{ts}The donor's information is listed below. You can choose to contact them and convey your thanks if you wish.{/ts}