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