2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
26 {* this template is used for adding/editing/deleting pledge *}
27 {if $showAdditionalInfo and $formType }
28 {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
30 {if !$email and $action neq 8 and $context neq 'standalone'}
31 <div class="messages status no-popup">
32 <div class="icon inform-icon"></div>
33 <p>{ts}You will not be able to send an acknowledgment for this pledge because there is no email address recorded for this contact. If you want a acknowledgment to be sent when this pledge is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the pledge.{/ts}</p>
37 {* Check if current Total Pledge Amount is different from original pledge amount. *}
38 {math equation="x / y" x=$amount y=$installments format="%.2f" assign="currentInstallment"}
39 {* Check if current Total Pledge Amount is different from original pledge amount. *}
40 {if $currentInstallment NEQ $eachPaymentAmount}
41 {assign var=originalPledgeAmount value=`$installments*$eachPaymentAmount`}
44 <div class="crm-block crm-form-block crm-pledge-form-block">
45 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
47 <div class="messages status no-popup">
48 <div class="icon inform-icon"></div>
49 <span class="font-red bold">{ts}WARNING: Deleting this pledge will also delete any related pledge payments.{/ts} {ts}This action cannot be undone.{/ts}</span>
50 <p>{ts}Consider cancelling the pledge instead if you want to maintain an audit trail and avoid losing payment data. To set the pledge status to Cancelled and cancel any not-yet-paid pledge payments, first click Cancel on this form. Then click the more > link from the pledge listing, and select the Cancel action.{/ts}</p>
53 <table class="form-layout-compressed">
54 {if $context eq 'standalone'}
55 <tr class="crm-pledge-form-contact-id">
56 <td class="label">{$form.contact_id.label}</td>
57 <td>{$form.contact_id.html}</td>
60 <tr class="crm-pledge-form-block-displayName">
61 <td class="font-size12pt right"><strong>{ts}Pledge by{/ts}</strong></td>
62 <td class="font-size12pt"><strong>{$displayName}</strong></td>
65 <tr class="crm-pledge-form-block-amount">
66 <td class="label">{$form.amount.label}</td>
68 <span>{$form.currency.html|crmAddClass:eight} {$form.amount.html|crmAddClass:eight}</span>
69 {if $originalPledgeAmount}<div class="messages status no-popup"><div class="icon inform-icon"></div> {ts 1=$originalPledgeAmount|crmMoney:$currency} Pledge total has changed due to payment adjustments. Original pledge amount was %1.{/ts}</div>{/if}
72 <tr class="crm-pledge-form-block-installments">
73 <td class="label">{$form.installments.label}</td>
74 <td>{$form.installments.html} {ts}installments of{/ts}
75 <span class='currency-symbol'>
76 {if $action eq 1 or $isPending}
77 {$form.eachPaymentAmount.html|crmMoney:$currency}
78 {elseif $action eq 2 and !$isPending}
79 {$eachPaymentAmount|crmMoney:$currency}
81 </span> {ts}every{/ts} {$form.frequency_interval.html} {$form.frequency_unit.html}
84 <tr class="crm-pledge-form-block-frequency_day">
85 <td class="label nowrap">{$form.frequency_day.label}</td>
86 <td>{$form.frequency_day.html} {ts}day of the period{/ts}<br />
87 <span class="description">{ts}This applies to weekly, monthly and yearly payments.{/ts}</span>
90 <tr class="crm-pledge-form-block-create_date">
91 <td class="label">{$form.create_date.label}</td>
93 {$form.create_date.html}<br />
94 <span class="description">{ts}Date when pledge was made by the contributor.{/ts}</span>
98 <tr class="crm-pledge-form-block-start_date">
99 <td class="label">{$form.start_date.label}</td>
101 {$form.start_date.html}<br />
102 <span class="description">{ts}Date of first pledge payment.{/ts}</span>
106 {if $email and $outBound_option != 2}
107 {if $form.is_acknowledge }
108 <tr class="crm-pledge-form-block-is_acknowledge">
109 <td class="label">{$form.is_acknowledge.label}</td>
110 <td>{$form.is_acknowledge.html}<br />
111 <span class="description">{ts 1=$email}Automatically email an acknowledgment of this pledge to %1?{/ts}</span>
115 {elseif $context eq 'standalone' and $outBound_option != 2 }
116 <tr id="acknowledgment-receipt" style="display:none;">
117 <td class="label">{$form.is_acknowledge.label}</td>
119 {$form.is_acknowledge.html} <span class="description">{ts 1='<span id="email-address"></span>'}Automatically email an acknowledgment of this pledge to %1?{/ts}</span>
123 <tr id="fromEmail" style="display:none;">
124 <td class="label">{$form.from_email_address.label}</td>
125 <td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td>
127 <tr id="acknowledgeDate">
128 <td class="label" class="crm-pledge-form-block-acknowledge_date">{$form.acknowledge_date.label}</td>
130 {$form.acknowledge_date.html}<br />
131 <span class="description">{ts}Date when an acknowledgment of the pledge was sent.{/ts}</span>
134 <tr class="crm-pledge-form-block-financial_type_id">
135 <td class="label">{$form.financial_type_id.label}</td>
136 <td>{$form.financial_type_id.html}<br />
137 <span class="description">{ts}Sets the default financial type for payments against this pledge.{/ts}</span>
141 {* CRM-7362 --add campaign *}
142 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
143 campaignTrClass="crm-pledge-form-block-campaign_id"}
145 <tr class="crm-pledge-form-block-contribution_page_id">
146 <td class="label">{$form.contribution_page_id.label}</td>
147 <td>{$form.contribution_page_id.html}<br />
148 <span class="description">{ts}Select an Online Contribution page that the user can access to make self-service pledge payments. (Only Online Contribution pages configured to include the Pledge option are listed.){/ts}</span>
152 <tr class="crm-pledge-form-block-status">
153 <td class="label"><label>{ts}Pledge Status{/ts}</label></td>
154 <td class="view-value">{$status}<br />
155 <span class="description">{ts}Pledges are "Pending" until the first payment is received. Once a payment is received, status is "In Progress" until all scheduled payments are completed. Overdue pledges are ones with payment(s) past due.{/ts}</span>
159 <td colspan=2>{include file="CRM/Custom/Form/CustomData.tpl"}</td>
163 <script type="text/javascript">
164 // bind first click of accordion header to load crm-accordion-body with snippet
165 // everything else taken care of by $().crm-accordions()
167 $('.crm-ajax-accordion .crm-accordion-header').one('click', function() {
168 loadPanes($(this).attr('id'));
170 $('#currency').on('change', function() {
171 replaceCurrency($('#currency option:selected').text());
173 $('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
174 loadPanes($(this).attr('id'));
177 function replaceCurrency(val) {
179 var eachPaymentAmout = $('#eachPaymentAmount');
180 var pos = val.indexOf("(") + 1;
182 symbol = val.slice(pos, val.lastIndexOf(")"));
184 $('.currency-symbol').text(symbol).append(" ").append(eachPaymentAmout);
187 // load panes function calls for snippet based on id of crm-accordion-header
188 function loadPanes( id ) {
189 var url = "{/literal}{crmURL p='civicrm/contact/view/pledge' q='snippet=4&formType=' h=0}{literal}" + id;
191 {if $contributionMode}
192 url = url + "&mode={$contributionMode}";
195 if ( ! $('div.'+id).html() ) {
196 var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" /> {/literal}{ts escape='js'}Loading{/ts}{literal}...';
197 $('div.'+id).html(loading);
200 success: function(data) { $('div.'+id).html(data).trigger('crmLoad'); }
209 <div class="accordion ui-accordion ui-widget ui-helper-reset">
210 {foreach from=$allPanes key=paneName item=paneValue}
211 <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
212 <div class="crm-accordion-header" id="{$paneValue.id}">
214 </div><!-- /.crm-accordion-header -->
215 <div class="crm-accordion-body">
216 <div class="{$paneValue.id}"></div>
217 </div><!-- /.crm-accordion-body -->
218 </div><!-- /.crm-accordion-wrapper -->
222 {/if} {* not delete mode if*}
225 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
228 <script type="text/javascript">
231 if (cj('#is_acknowledge').is(':checked')) {
232 var emailAddress = '{/literal}{$email}{literal}';
233 if ( !emailAddress ) {
234 var emailAddress = cj('#email-address').html();
236 var message = '{/literal}{ts escape="js" 1="%1"}Click OK to save this Pledge record AND send an acknowledgment to %1 now.{/ts}{literal}';
237 return confirm(ts(message, {1: emailAddress}));
241 function calculatedPaymentAmount( ) {
242 var thousandMarker = {/literal}{crmSetting name="monetaryThousandSeparator" group="CiviCRM Localization"}{literal};
243 var seperator = '{/literal}{$config->monetaryDecimalPoint}{literal}';
244 var amount = document.getElementById("amount").value;
245 // replace all thousandMarker and change the seperator to a dot
246 amount = amount.replace(thousandMarker,'').replace(seperator,'.');
247 var installments = document.getElementById("installments").value;
248 if ( installments != '' && installments != NaN) {
249 amount = amount/installments;
250 var installmentAmount = formatMoney( amount, 2, seperator, thousandMarker );
251 document.getElementById("eachPaymentAmount").value = installmentAmount;
255 function formatMoney (amount, c, d, t){
257 c = isNaN(c = Math.abs(c)) ? 2 : c,
258 d = d == undefined ? "," : d,
259 t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
260 i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
261 j = (j = i.length) > 3 ? j % 3 : 0;
262 return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
266 {if $context eq 'standalone' and $outBound_option != 2 }
269 var $form = $("form.{/literal}{$form.formClass}{literal}");
270 $("#contact_id", $form).change(checkEmail);
273 function checkEmail( ) {
274 var data = $("#contact_id", $form).select2('data');
275 if (data && data.extra && data.extra.email && data.extra.email.length) {
276 $("#acknowledgment-receipt", $form).show();
277 $("#email-address", $form).html(data.extra.email);
280 $("#acknowledgment-receipt", $form).hide();
284 showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true);
285 showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );
292 {if $email and $outBound_option != 2}
293 {include file="CRM/common/showHideByFieldValue.tpl"
294 trigger_field_id ="is_acknowledge"
296 target_element_id ="acknowledgeDate"
297 target_element_type ="table-row"
301 {include file="CRM/common/showHideByFieldValue.tpl"
302 trigger_field_id ="is_acknowledge"
304 target_element_id ="fromEmail"
305 target_element_type ="table-row"
311 {* closing of main custom data if *}