copyright and version fixes
[civicrm-core.git] / templates / CRM / Pledge / Form / Pledge.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
232624b1 3 | CiviCRM version 4.4 |
6a488035
TO
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 *}
27{if $cdType}
28 {include file="CRM/Custom/Form/CustomData.tpl"}
29{elseif $showAdditionalInfo and $formType }
30 {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
31{else}
32{if !$email and $action neq 8 and $context neq 'standalone'}
33<div class="messages status no-popup">
34 <div class="icon inform-icon"></div>
35 <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>
36</div>
37{/if}
38{if $action EQ 1}
39 <h3>{ts}New Pledge{/ts}</h3>
40{elseif $action EQ 2}
41 <h3>{ts}Edit Pledge{/ts}</h3>
42 {* Check if current Total Pledge Amount is different from original pledge amount. *}
43 {math equation="x / y" x=$amount y=$installments format="%.2f" assign="currentInstallment"}
44 {* Check if current Total Pledge Amount is different from original pledge amount. *}
45 {if $currentInstallment NEQ $eachPaymentAmount}
46 {assign var=originalPledgeAmount value=`$installments*$eachPaymentAmount`}
47 {/if}
48{elseif $action EQ 8}
49 <h3>{ts}Delete Pledge{/ts}</h3>
50{/if}
51<div class="crm-block crm-form-block crm-pledge-form-block">
52 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
53 {if $action eq 8}
54 <div class="messages status no-popup">
55 <div class="icon inform-icon"></div>&nbsp;
56 <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>
57 <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 &gt; link from the pledge listing, and select the Cancel action.{/ts}</p>
58 </div>
59 {else}
60 <table class="form-layout-compressed">
61 {if $context eq 'standalone'}
b9aa8f56
CW
62 {if !$email and $outBound_option != 2}
63 {assign var='profileCreateCallback' value=1 }
64 {/if}
65 <tr class="crm-pledge-form-contact-id">
66 <td class="label">{$form.contact_id.label}</td>
67 <td>{$form.contact_id.html}</td>
68 </tr>
6a488035
TO
69 {else}
70 <tr class="crm-pledge-form-block-displayName">
71 <td class="font-size12pt right"><strong>{ts}Pledge by{/ts}</strong></td>
72 <td class="font-size12pt"><strong>{$displayName}</strong></td>
73 </tr>
74 {/if}
75 <tr class="crm-pledge-form-block-amount">
76 <td class="label">{$form.amount.label}</td>
77 <td><span>{$form.currency.html|crmAddClass:eight}&nbsp;{$form.amount.html|crmAddClass:eight}</span>
78 {if $originalPledgeAmount}<div class="messages status no-popup"><div class="icon inform-icon"></div>&nbsp;{ts 1=$originalPledgeAmount|crmMoney:$currency} Pledge total has changed due to payment adjustments. Original pledge amount was %1.{/ts}</div>{/if}
79 </td>
80 </tr>
81 <tr class="crm-pledge-form-block-installments">
82 <td class="label">{$form.installments.label}</td>
83 <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}&nbsp;{ts}every{/ts}&nbsp;{$form.frequency_interval.html}&nbsp;{$form.frequency_unit.html}</td></tr>
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}</td></tr>
88 {if $form.create_date}
89 <tr class="crm-pledge-form-block-create_date">
90 <td class="label">{$form.create_date.label}</td>
91 <td>{include file="CRM/common/jcalendar.tpl" elementName=create_date}<br />
92 {/if}
93 {if $create_date}
94 <tr class="crm-pledge-form-block-create_date">
95 <td class="label">{ts}Pledge Made{/ts}</td>
96 <td class="view-value">{$create_date|truncate:10:''|crmDate}
97 {/if}<br />
98 <span class="description">{ts}Date when pledge was made by the contributor.{/ts}</span></td></tr>
99
100 {if $form.start_date}
101 <tr class="crm-pledge-form-block-start_date">
102 <td class="label">{$form.start_date.label}</td>
103 <td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}<br />
104 {/if}
105 {if $start_date}
106 <tr class="crm-pledge-form-block-start_date">
107 <td class="label">{ts}Payments Start{/ts}</td>
108 <td class="view-value">{$start_date|truncate:10:''|crmDate}
109 {/if}<br />
110 <span class="description">{ts}Date of first pledge payment.{/ts}</span></td></tr>
111
112 {if $email and $outBound_option != 2}
113 {if $form.is_acknowledge }
114 <tr class="crm-pledge-form-block-is_acknowledge">
115 <td class="label">{$form.is_acknowledge.label}</td>
116 <td>{$form.is_acknowledge.html}<br />
117 <span class="description">{ts 1=$email}Automatically email an acknowledgment of this pledge to %1?{/ts}</span></td></tr>
118 {/if}
119 {elseif $context eq 'standalone' and $outBound_option != 2 }
120 <tr id="acknowledgment-receipt" style="display:none;"><td class="label">{$form.is_acknowledge.label}</td><td>{$form.is_acknowledge.html} <span class="description">{ts}Automatically email an acknowledgment of this pledge to {/ts}<span id="email-address"></span>?</span></td></tr>
121 {/if}
122 <tr id="fromEmail" style="display:none;">
123 <td class="label">{$form.from_email_address.label}</td>
124 <td>{$form.from_email_address.html}</td>
125 </tr>
126 <tr id="acknowledgeDate">
127 <td class="label" class="crm-pledge-form-block-acknowledge_date">{$form.acknowledge_date.label}</td>
128 <td>{include file="CRM/common/jcalendar.tpl" elementName=acknowledge_date}<br />
129 <span class="description">{ts}Date when an acknowledgment of the pledge was sent.{/ts}</span></td>
130 </tr>
131 <tr class="crm-pledge-form-block-financial_type_id">
132 <td class="label">{$form.financial_type_id.label}</td>
133 <td>{$form.financial_type_id.html}<br />
134 <span class="description">{ts}Sets the default financial type for payments against this pledge.{/ts}</span></td></tr>
135
136 {* CRM-7362 --add campaign *}
137 {include file="CRM/Campaign/Form/addCampaignToComponent.tpl"
138 campaignTrClass="crm-pledge-form-block-campaign_id"}
139
140 <tr class="crm-pledge-form-block-contribution_page_id">
141 <td class="label">{$form.contribution_page_id.label}</td>
142 <td>{$form.contribution_page_id.html}<br />
143 <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>
144 </tr>
145
146 <tr class="crm-pledge-form-block-status">
147 <td class="label">{ts}Pledge Status{/ts}</td>
148 <td class="view-value">{$status}<br />
149 <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>
150 <tr><td colspan=2>{include file="CRM/Custom/Form/CustomData.tpl"}</td></tr>
151 </table>
152{literal}
153<script type="text/javascript">
154// bind first click of accordion header to load crm-accordion-body with snippet
155// everything else taken care of by cj().crm-accordions()
156cj(document).ready( function() {
157 cj('.crm-ajax-accordion .crm-accordion-header').one('click', function() {
158 loadPanes(cj(this).attr('id'));
159 });
160 cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function(index) {
161 loadPanes(cj(this).attr('id'));
162 });
163});
164// load panes function calls for snippet based on id of crm-accordion-header
165function loadPanes( id ) {
166 var url = "{/literal}{crmURL p='civicrm/contact/view/pledge' q='snippet=4&formType=' h=0}{literal}" + id;
167 {/literal}
168 {if $contributionMode}
169 url = url + "&mode={$contributionMode}";
170 {/if}
171 {literal}
172 if ( ! cj('div.'+id).html() ) {
173 var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" />&nbsp;{/literal}{ts escape='js'}Loading{/ts}{literal}...';
174 cj('div.'+id).html(loading);
175 cj.ajax({
176 url : url,
b22f0cad 177 success: function(data) { cj('div.'+id).html(data).trigger('crmLoad'); }
6a488035
TO
178 });
179 }
180 }
181</script>
182{/literal}
183
184
185<div class="accordion ui-accordion ui-widget ui-helper-reset">
186{foreach from=$allPanes key=paneName item=paneValue}
187<div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
188<div class="crm-accordion-header" id="{$paneValue.id}">
189 {$paneName}
190 </div><!-- /.crm-accordion-header -->
191 <div class="crm-accordion-body">
192 <div class="{$paneValue.id}"></div>
193 </div><!-- /.crm-accordion-body -->
194</div><!-- /.crm-accordion-wrapper -->
195
196{/foreach}
197</div>
198{/if} {* not delete mode if*}
199
200<br />
201<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
202</div>
203{literal}
204<script type="text/javascript">
205cj(function() {
206 cj().crmAccordions();
207});
208</script>
209{/literal}
210{literal}
211 <script type="text/javascript">
212
213 function verify( ) {
214 var element = document.getElementsByName("is_acknowledge");
215 if ( element[0].checked ) {
216 var emailAddress = '{/literal}{$email}{literal}';
217 if ( !emailAddress ) {
218 var emailAddress = cj('#email-address').html();
219 }
220 var message = '{/literal}{ts 1="'+emailAddress+'"}Click OK to save this Pledge record AND send an acknowledgment to %1 now{/ts}{literal}.';
221 if (!confirm( message) ) {
222 return false;
223 }
224 }
225 }
226
227 function calculatedPaymentAmount( ) {
228 var thousandMarker = {/literal}{crmSetting name="monetaryThousandSeparator" group="CiviCRM Localization"}{literal};
229 var seperator = '{/literal}{$config->monetaryDecimalPoint}{literal}';
230 var amount = document.getElementById("amount").value;
231 // replace all thousandMarker and change the seperator to a dot
232 amount = amount.replace(thousandMarker,'').replace(seperator,'.');
233 var installments = document.getElementById("installments").value;
234 if ( installments != '' && installments != NaN) {
235 amount = amount/installments;
236 var installmentAmount = formatMoney( amount, 2, seperator, thousandMarker );
237 document.getElementById("eachPaymentAmount").value = installmentAmount;
238 }
239 }
240
241 function formatMoney (amount, c, d, t){
242 var n = amount,
243 c = isNaN(c = Math.abs(c)) ? 2 : c,
244 d = d == undefined ? "," : d,
245 t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
246 i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
247 j = (j = i.length) > 3 ? j % 3 : 0;
248 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) : "");
249 };
250
251 {/literal}
252 {if $context eq 'standalone' and $outBound_option != 2 }
253 {literal}
254 cj( function( ) {
255 cj("#contact_1").blur( function( ) {
256 checkEmail( );
257 });
258 checkEmail( );
259 showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true);
260 showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );
261 });
262 function checkEmail( ) {
263 var contactID = cj("input[name='contact_select_id[1]']").val();
264 if ( contactID ) {
265 var postUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' h=0}{literal}";
266 cj.post( postUrl, {contact_id: contactID},
267 function ( response ) {
268 if ( response ) {
269 cj("#acknowledgment-receipt").show( );
270 cj("#email-address").html( response );
271 } else {
272 cj("#acknowledgment-receipt").hide( );
273 }
274 }
275 );
276 } else {
277 cj("#acknowledgment-receipt").hide( );
278 }
279 }
280
281 function profileCreateCallback( blockNo ) {
282 checkEmail( );
283 }
284 {/literal}
285 {/if}
286</script>
287
288{if $email and $outBound_option != 2}
289{include file="CRM/common/showHideByFieldValue.tpl"
290 trigger_field_id ="is_acknowledge"
291 trigger_value =""
292 target_element_id ="acknowledgeDate"
293 target_element_type ="table-row"
294 field_type ="radio"
295 invert = 1
296}
297{include file="CRM/common/showHideByFieldValue.tpl"
298 trigger_field_id ="is_acknowledge"
299 trigger_value =""
300 target_element_id ="fromEmail"
301 target_element_type ="table-row"
302 field_type ="radio"
303 invert = 0
304}
305{/if}
306
307 {* include jscript to warn if unsaved form field changes *}
308 {include file="CRM/common/formNavigate.tpl"}
309
310{/if}
311{* closing of main custom data if *}