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