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