Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
fee14197 | 3 | | CiviCRM version 5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
6b83d5bd | 5 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
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. | | |
12 | | | | |
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. | | |
17 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {* this template is used for adding/editing/deleting pledge *} | |
39082712 | 27 | {if $showAdditionalInfo and $formType } |
6a488035 TO |
28 | {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"} |
29 | {else} | |
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> | |
62ad622d | 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> |
6a488035 TO |
34 | </div> |
35 | {/if} | |
e2046b33 | 36 | {if $action EQ 2} |
6a488035 TO |
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`} | |
42 | {/if} | |
6a488035 TO |
43 | {/if} |
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> | |
46 | {if $action eq 8} | |
47 | <div class="messages status no-popup"> | |
62ad622d MR |
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> | |
6a488035 TO |
51 | </div> |
52 | {else} | |
53 | <table class="form-layout-compressed"> | |
b9aa8f56 CW |
54 | <tr class="crm-pledge-form-contact-id"> |
55 | <td class="label">{$form.contact_id.label}</td> | |
56 | <td>{$form.contact_id.html}</td> | |
57 | </tr> | |
62ad622d MR |
58 | <tr class="crm-pledge-form-block-amount"> |
59 | <td class="label">{$form.amount.label}</td> | |
60 | <td> | |
61 | <span>{$form.currency.html|crmAddClass:eight} {$form.amount.html|crmAddClass:eight}</span> | |
62 | {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} | |
63 | </td> | |
64 | </tr> | |
65 | <tr class="crm-pledge-form-block-installments"> | |
66 | <td class="label">{$form.installments.label}</td> | |
67 | <td>{$form.installments.html} {ts}installments of{/ts} | |
68 | <span class='currency-symbol'> | |
69 | {if $action eq 1 or $isPending} | |
70 | {$form.eachPaymentAmount.html|crmMoney:$currency} | |
71 | {elseif $action eq 2 and !$isPending} | |
72 | {$eachPaymentAmount|crmMoney:$currency} | |
73 | {/if} | |
74 | </span> {ts}every{/ts} {$form.frequency_interval.html} {$form.frequency_unit.html} | |
75 | </td> | |
76 | </tr> | |
77 | <tr class="crm-pledge-form-block-frequency_day"> | |
78 | <td class="label nowrap">{$form.frequency_day.label}</td> | |
79 | <td>{$form.frequency_day.html} {ts}day of the period{/ts}<br /> | |
80 | <span class="description">{ts}This applies to weekly, monthly and yearly payments.{/ts}</span> | |
81 | </td> | |
82 | </tr> | |
62ad622d | 83 | <tr class="crm-pledge-form-block-create_date"> |
6a488035 | 84 | <td class="label">{$form.create_date.label}</td> |
09edd4bd CW |
85 | <td> |
86 | {$form.create_date.html}<br /> | |
87 | <span class="description">{ts}Date when pledge was made by the contributor.{/ts}</span> | |
62ad622d MR |
88 | </td> |
89 | </tr> | |
6a488035 | 90 | |
62ad622d MR |
91 | <tr class="crm-pledge-form-block-start_date"> |
92 | <td class="label">{$form.start_date.label}</td> | |
09edd4bd CW |
93 | <td> |
94 | {$form.start_date.html}<br /> | |
62ad622d MR |
95 | <span class="description">{ts}Date of first pledge payment.{/ts}</span> |
96 | </td> | |
97 | </tr> | |
6a488035 TO |
98 | |
99 | {if $email and $outBound_option != 2} | |
100 | {if $form.is_acknowledge } | |
62ad622d MR |
101 | <tr class="crm-pledge-form-block-is_acknowledge"> |
102 | <td class="label">{$form.is_acknowledge.label}</td> | |
103 | <td>{$form.is_acknowledge.html}<br /> | |
104 | <span class="description">{ts 1=$email}Automatically email an acknowledgment of this pledge to %1?{/ts}</span> | |
105 | </td> | |
106 | </tr> | |
6a488035 | 107 | {/if} |
62ad622d MR |
108 | {elseif $context eq 'standalone' and $outBound_option != 2 } |
109 | <tr id="acknowledgment-receipt" style="display:none;"> | |
110 | <td class="label">{$form.is_acknowledge.label}</td> | |
111 | <td> | |
112 | {$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> | |
113 | </td> | |
114 | </tr> | |
6a488035 | 115 | {/if} |
62ad622d | 116 | <tr id="fromEmail" style="display:none;"> |
6a488035 | 117 | <td class="label">{$form.from_email_address.label}</td> |
c351f795 | 118 | <td>{$form.from_email_address.html} {help id="id-from_email" file="CRM/Contact/Form/Task/Email.hlp" isAdmin=$isAdmin}</td> |
62ad622d MR |
119 | </tr> |
120 | <tr id="acknowledgeDate"> | |
121 | <td class="label" class="crm-pledge-form-block-acknowledge_date">{$form.acknowledge_date.label}</td> | |
09edd4bd CW |
122 | <td> |
123 | {$form.acknowledge_date.html}<br /> | |
62ad622d MR |
124 | <span class="description">{ts}Date when an acknowledgment of the pledge was sent.{/ts}</span> |
125 | </td> | |
126 | </tr> | |
127 | <tr class="crm-pledge-form-block-financial_type_id"> | |
128 | <td class="label">{$form.financial_type_id.label}</td> | |
129 | <td>{$form.financial_type_id.html}<br /> | |
130 | <span class="description">{ts}Sets the default financial type for payments against this pledge.{/ts}</span> | |
131 | </td> | |
132 | </tr> | |
6a488035 TO |
133 | |
134 | {* CRM-7362 --add campaign *} | |
135 | {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" | |
136 | campaignTrClass="crm-pledge-form-block-campaign_id"} | |
137 | ||
62ad622d MR |
138 | <tr class="crm-pledge-form-block-contribution_page_id"> |
139 | <td class="label">{$form.contribution_page_id.label}</td> | |
140 | <td>{$form.contribution_page_id.html}<br /> | |
141 | <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> | |
142 | </td> | |
143 | </tr> | |
6a488035 | 144 | |
62ad622d MR |
145 | <tr class="crm-pledge-form-block-status"> |
146 | <td class="label"><label>{ts}Pledge Status{/ts}</label></td> | |
147 | <td class="view-value">{$status}<br /> | |
148 | <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> | |
149 | </td> | |
150 | </tr> | |
151 | <tr> | |
152 | <td colspan=2>{include file="CRM/Custom/Form/CustomData.tpl"}</td> | |
153 | </tr> | |
6a488035 TO |
154 | </table> |
155 | {literal} | |
156 | <script type="text/javascript"> | |
025cf9a2 | 157 | // bind first click of accordion header to load crm-accordion-body with snippet |
158 | // everything else taken care of by $().crm-accordions() | |
159 | CRM.$(function($) { | |
160 | $('.crm-ajax-accordion .crm-accordion-header').one('click', function() { | |
161 | loadPanes($(this).attr('id')); | |
6a488035 | 162 | }); |
025cf9a2 | 163 | $('#currency').on('change', function() { |
164 | replaceCurrency($('#currency option:selected').text()); | |
1fb7bdc9 | 165 | }); |
025cf9a2 | 166 | $('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) { |
167 | loadPanes($(this).attr('id')); | |
1fb7bdc9 | 168 | }); |
1fb7bdc9 | 169 | |
025cf9a2 | 170 | function replaceCurrency(val) { |
fb45cb28 | 171 | var symbol = ''; |
025cf9a2 | 172 | var eachPaymentAmout = $('#eachPaymentAmount'); |
173 | var pos = val.indexOf("(") + 1; | |
174 | if (pos) { | |
fb45cb28 | 175 | symbol = val.slice(pos, val.lastIndexOf(")")); |
025cf9a2 | 176 | } |
fb45cb28 | 177 | $('.currency-symbol').text(symbol).append(" ").append(eachPaymentAmout); |
025cf9a2 | 178 | } |
1fb7bdc9 | 179 | |
025cf9a2 | 180 | // load panes function calls for snippet based on id of crm-accordion-header |
181 | function loadPanes( id ) { | |
182 | var url = "{/literal}{crmURL p='civicrm/contact/view/pledge' q='snippet=4&formType=' h=0}{literal}" + id; | |
183 | {/literal} | |
6a488035 | 184 | {if $contributionMode} |
025cf9a2 | 185 | url = url + "&mode={$contributionMode}"; |
6a488035 | 186 | {/if} |
025cf9a2 | 187 | {literal} |
188 | if ( ! $('div.'+id).html() ) { | |
189 | 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}...'; | |
190 | $('div.'+id).html(loading); | |
191 | $.ajax({ | |
6a488035 | 192 | url : url, |
025cf9a2 | 193 | success: function(data) { $('div.'+id).html(data).trigger('crmLoad'); } |
194 | }); | |
6a488035 | 195 | } |
025cf9a2 | 196 | } |
197 | }); | |
6a488035 TO |
198 | </script> |
199 | {/literal} | |
200 | ||
201 | ||
202 | <div class="accordion ui-accordion ui-widget ui-helper-reset"> | |
203 | {foreach from=$allPanes key=paneName item=paneValue} | |
204 | <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}"> | |
205 | <div class="crm-accordion-header" id="{$paneValue.id}"> | |
206 | {$paneName} | |
207 | </div><!-- /.crm-accordion-header --> | |
208 | <div class="crm-accordion-body"> | |
209 | <div class="{$paneValue.id}"></div> | |
210 | </div><!-- /.crm-accordion-body --> | |
211 | </div><!-- /.crm-accordion-wrapper --> | |
212 | ||
213 | {/foreach} | |
214 | </div> | |
215 | {/if} {* not delete mode if*} | |
216 | ||
217 | <br /> | |
218 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
219 | </div> | |
6a488035 TO |
220 | {literal} |
221 | <script type="text/javascript"> | |
222 | ||
223 | function verify( ) { | |
d28b0643 | 224 | if (cj('#is_acknowledge').is(':checked')) { |
6a488035 TO |
225 | var emailAddress = '{/literal}{$email}{literal}'; |
226 | if ( !emailAddress ) { | |
227 | var emailAddress = cj('#email-address').html(); | |
228 | } | |
5bbaf68b CW |
229 | var message = '{/literal}{ts escape="js" 1="%1"}Click OK to save this Pledge record AND send an acknowledgment to %1 now.{/ts}{literal}'; |
230 | return confirm(ts(message, {1: emailAddress})); | |
6a488035 TO |
231 | } |
232 | } | |
233 | ||
234 | function calculatedPaymentAmount( ) { | |
235 | var thousandMarker = {/literal}{crmSetting name="monetaryThousandSeparator" group="CiviCRM Localization"}{literal}; | |
236 | var seperator = '{/literal}{$config->monetaryDecimalPoint}{literal}'; | |
237 | var amount = document.getElementById("amount").value; | |
238 | // replace all thousandMarker and change the seperator to a dot | |
239 | amount = amount.replace(thousandMarker,'').replace(seperator,'.'); | |
240 | var installments = document.getElementById("installments").value; | |
241 | if ( installments != '' && installments != NaN) { | |
242 | amount = amount/installments; | |
243 | var installmentAmount = formatMoney( amount, 2, seperator, thousandMarker ); | |
244 | document.getElementById("eachPaymentAmount").value = installmentAmount; | |
245 | } | |
246 | } | |
247 | ||
248 | function formatMoney (amount, c, d, t){ | |
249 | var n = amount, | |
250 | c = isNaN(c = Math.abs(c)) ? 2 : c, | |
251 | d = d == undefined ? "," : d, | |
252 | t = t == undefined ? "." : t, s = n < 0 ? "-" : "", | |
253 | i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", | |
254 | j = (j = i.length) > 3 ? j % 3 : 0; | |
255 | 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) : ""); | |
256 | }; | |
257 | ||
258 | {/literal} | |
259 | {if $context eq 'standalone' and $outBound_option != 2 } | |
260 | {literal} | |
3cc60a06 | 261 | CRM.$(function($) { |
b50fdacc | 262 | var $form = $("form.{/literal}{$form.formClass}{literal}"); |
ae8f569f CW |
263 | $("#contact_id", $form).change(checkEmail); |
264 | checkEmail( ); | |
265 | ||
266 | function checkEmail( ) { | |
267 | var data = $("#contact_id", $form).select2('data'); | |
268 | if (data && data.extra && data.extra.email && data.extra.email.length) { | |
269 | $("#acknowledgment-receipt", $form).show(); | |
270 | $("#email-address", $form).html(data.extra.email); | |
271 | } | |
272 | else { | |
273 | $("#acknowledgment-receipt", $form).hide(); | |
274 | } | |
275 | } | |
276 | ||
277 | showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); | |
278 | showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false ); | |
6a488035 | 279 | }); |
6a488035 | 280 | |
6a488035 TO |
281 | {/literal} |
282 | {/if} | |
283 | </script> | |
284 | ||
285 | {if $email and $outBound_option != 2} | |
286 | {include file="CRM/common/showHideByFieldValue.tpl" | |
287 | trigger_field_id ="is_acknowledge" | |
288 | trigger_value ="" | |
289 | target_element_id ="acknowledgeDate" | |
290 | target_element_type ="table-row" | |
291 | field_type ="radio" | |
292 | invert = 1 | |
293 | } | |
294 | {include file="CRM/common/showHideByFieldValue.tpl" | |
295 | trigger_field_id ="is_acknowledge" | |
296 | trigger_value ="" | |
297 | target_element_id ="fromEmail" | |
298 | target_element_type ="table-row" | |
299 | field_type ="radio" | |
300 | invert = 0 | |
301 | } | |
302 | {/if} | |
6a488035 TO |
303 | {/if} |
304 | {* closing of main custom data if *} |