From: Kurund Jalmi Date: Tue, 30 Apr 2013 18:26:24 +0000 (-0700) Subject: Merge pull request #583 from yashodha/CRM-12463 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3587381cb6fe49cb6628b9348906a6ad3043bec9;hp=44ca2a2f8a9da79b5e3395eb2d0dbfc7402b14e8;p=civicrm-core.git Merge pull request #583 from yashodha/CRM-12463 CRM-12463 --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index b19ff6219b..6595754045 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -842,6 +842,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $this->addElement('textarea', 'pcp_personal_note', ts('Personal Note (for Honor Roll)')); } + CRM_Contribute_Form_SoftCredit::buildQuickForm($this); + + /* // If we have a contact for this contribution, pass cid= to the dataUrl to exclude current contact from autocomplete results if ($this->_contactID) { $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', @@ -855,13 +858,14 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP ); } $this->assign('dataUrl', $dataUrl); + $this->addElement('text', 'soft_credit_to', ts('Soft Credit To')); // Tell tpl to hide Soft Credit field if contribution is linked directly to a PCP Page if (CRM_Utils_Array::value('pcp_made_through_id', $this->_values)) { $this->assign('pcpLinked', 1); } $this->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id')); - + */ $js = NULL; if (!$this->_mode) { $js = array('onclick' => "return verify( );"); diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php new file mode 100644 index 0000000000..dc4ffa7b58 --- /dev/null +++ b/CRM/Contribute/Form/SoftCredit.php @@ -0,0 +1,77 @@ +_softCredit['item_count']; $rowNumber++) { + CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, TRUE, 'soft_credit_'); + } + + // If we have a contact for this contribution, pass cid= to the dataUrl to exclude current contact from autocomplete results + if ($form->_contactID) { + $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', + "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1&context=softcredit&cid={$form->_contactID}", + FALSE, NULL, FALSE + ); + } + else { + $dataUrl = CRM_Utils_System::url('civicrm/ajax/rest', + 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1&context=softcredit', + FALSE, NULL, FALSE + ); + } + $form->assign('dataUrl', $dataUrl); + + $form->addElement('text', 'soft_credit_to', ts('Soft Credit To')); + // Tell tpl to hide Soft Credit field if contribution is linked directly to a PCP Page + if (CRM_Utils_Array::value('pcp_made_through_id', $form->_values)) { + $form->assign('pcpLinked', 1); + } + $form->addElement('hidden', 'soft_contact_id', '', array('id' => 'soft_contact_id')); + } +} + diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 065f150c06..d3130de130 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -219,44 +219,16 @@ {/if} - {$form.soft_credit_to.label} - - {$form.soft_credit_to.html} {help id="id-soft_credit"} - {if $siteHasPCPs} - - {/if} - - - {if $siteHasPCPs}{* Credit contribution to PCP. *} - - {$form.pcp_made_through.label} - - {$form.pcp_made_through.html}   - {ts}unlink from personal campaign page{/ts}
- {ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts} -
-
- - - - - - - - - - - - -
{$form.pcp_display_in_roll.label}{$form.pcp_display_in_roll.html}
{$form.pcp_roll_nickname.label}{$form.pcp_roll_nickname.html|crmAddClass:big}
- {ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}
{$form.pcp_personal_note.label}{$form.pcp_personal_note.html} - {ts}Personal message submitted by contributor for display in the Honor Roll.{/ts} -
-
- - - {/if} + +
+
+ {ts}Soft Credit{/ts} +
+
+ {include file="CRM/Contribute/Form/SoftCredit.tpl"} +
+
{if !$contributionMode}
@@ -365,10 +337,6 @@ var url = "{/literal}{$dataUrl}{literal}"; - cj('#soft_credit_to').autocomplete( url, { width : 180, selectFirst : false, matchContains: true - }).result( function(event, data, formatted) { - cj( "#soft_contact_id" ).val( data[1] ); - }); {/literal} {if $context eq 'standalone' and $outBound_option != 2 } {literal} @@ -524,42 +492,6 @@ cj(function() { // load form during form rule. {if $buildPriceSet}{literal}buildAmount( );{/literal}{/if} -{if $siteHasPCPs} - {literal} - var pcpUrl = "{/literal}{$pcpDataUrl}{literal}"; - - cj('#pcp_made_through').autocomplete( pcpUrl, { width : 360, selectFirst : false, matchContains: true - }).result( function(event, data, formatted) { - cj( "#pcp_made_through_id" ).val( data[1] ); - }); -{/literal} - - {if $pcpLinked} - {literal}hideSoftCredit( );{/literal}{* hide soft credit on load if we have PCP linkage *} - {else} - {literal}cj('#pcpID').hide();{/literal}{* hide PCP section *} - {/if} - - {literal} - function hideSoftCredit ( ){ - cj("#softCreditID").hide(); - } - function showPCP( ) { - cj('#pcpID').show(); - cj("#softCreditID").hide(); - } - function showSoftCredit( ) { - cj('#pcp_made_through_id').val(''); - cj('#pcp_made_through').val(''); - cj('#pcp_roll_nickname').val(''); - cj('#pcp_personal_note').val(''); - cj('#pcp_display_in_roll').attr('checked', false); - cj("#pcpID").hide(); - cj('#softCreditID').show(); - } - {/literal} -{/if} - {literal} function buildAmount( priceSetId ) { if (!priceSetId) priceSetId = cj("#price_set_id").val( ); diff --git a/templates/CRM/Contribute/Form/SoftCredit.tpl b/templates/CRM/Contribute/Form/SoftCredit.tpl new file mode 100644 index 0000000000..27ba3801e1 --- /dev/null +++ b/templates/CRM/Contribute/Form/SoftCredit.tpl @@ -0,0 +1,119 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.3 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2013 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{* template for adding form elements for soft credit form*} + {$form.soft_credit_to.label} + + {$form.soft_credit_to.html} {help id="id-soft_credit"} + {if $siteHasPCPs} + + {/if} + + + {if $siteHasPCPs}{* Credit contribution to PCP. *} + + {$form.pcp_made_through.label} + + {$form.pcp_made_through.html}   + {ts}unlink from personal campaign page{/ts}
+ {ts}Search for the Personal Campaign Page by the fund-raiser's last name or email address.{/ts} +
+
+ + + + + + + + + + + + +
{$form.pcp_display_in_roll.label}{$form.pcp_display_in_roll.html}
{$form.pcp_roll_nickname.label}{$form.pcp_roll_nickname.html|crmAddClass:big}
+ {ts}Name or nickname contributor wants to be displayed in the Honor Roll. Enter "Anonymous" for anonymous contributions.{/ts}
{$form.pcp_personal_note.label}{$form.pcp_personal_note.html} + {ts}Personal message submitted by contributor for display in the Honor Roll.{/ts} +
+
+ + + {/if} + + {literal} + + + + + + +