Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | {*common template for compose PDF letters*} | |
27 | {if $form.template.html} | |
28 | <table class="form-layout-compressed"> | |
29 | <tr> | |
4c71ccb4 | 30 | <td class="label-left">{$form.template.label}</td> |
6a488035 TO |
31 | <td>{$form.template.html}</td> |
32 | </tr> | |
4c71ccb4 RN |
33 | <tr> |
34 | <td class="label-left">{$form.subject.label}</td> | |
35 | <td>{$form.subject.html}</td> | |
36 | </tr> | |
37 | <tr> | |
38 | <td class="label-left">{$form.campaign_id.label}</td> | |
39 | <td>{$form.campaign_id.html}</td> | |
40 | </tr> | |
6a488035 TO |
41 | </table> |
42 | {/if} | |
43 | ||
44 | <div class="crm-accordion-wrapper collapsed"> | |
45 | <div class="crm-accordion-header"> | |
46 | {$form.pdf_format_header.html} | |
47 | </div> | |
48 | <div class="crm-accordion-body"> | |
49 | <div class="crm-block crm-form-block crm-pdf-format-form-block"> | |
50 | <table class="form-layout-compressed"> | |
51 | <tr> | |
a7916823 CW |
52 | <td class="label-left">{$form.format_id.label} {help id="id-pdf-format" file="CRM/Contact/Form/Task/PDFLetterCommon.hlp"}</td> |
53 | <td>{$form.format_id.html}</td> | |
54 | </tr> | |
6a488035 TO |
55 | <tr> |
56 | <td class="label-left">{$form.paper_size.label}</td><td>{$form.paper_size.html}</td> | |
57 | <td class="label-left">{$form.orientation.label}</td><td>{$form.orientation.html}</td> | |
58 | </tr> | |
59 | <tr> | |
60 | <td class="label-left">{$form.metric.label}</td><td>{$form.metric.html}</td> | |
61 | <td colspan="2"> </td> | |
62 | </tr> | |
63 | <tr> | |
64 | <td>{$form.paper_dimensions.html}</td><td id="paper_dimensions"> </td> | |
65 | <td colspan="2"> </td> | |
66 | </tr> | |
67 | <tr> | |
68 | <td class="label-left">{$form.margin_top.label}</td><td>{$form.margin_top.html}</td> | |
69 | <td class="label-left">{$form.margin_bottom.label}</td><td>{$form.margin_bottom.html}</td> | |
70 | </tr> | |
71 | <tr> | |
72 | <td class="label-left">{$form.margin_left.label}</td><td>{$form.margin_left.html}</td> | |
73 | <td class="label-left">{$form.margin_right.label}</td><td>{$form.margin_right.html}</td> | |
74 | </tr> | |
bdfa67c3 | 75 | <tr> |
76 | <td class="label-left">{$form.stationery.label}</td><td>{$form.stationery.html}</td> | |
77 | <td colspan="2"> </td> | |
78 | </tr> | |
6a488035 TO |
79 | </table> |
80 | <div id="bindFormat">{$form.bind_format.html} {$form.bind_format.label}</div> | |
81 | <div id="updateFormat" style="display: none">{$form.update_format.html} {$form.update_format.label}</div> | |
82 | </div> | |
83 | </div> | |
84 | </div> | |
85 | ||
86 | <div class="crm-accordion-wrapper crm-html_email-accordion "> | |
87 | <div class="crm-accordion-header"> | |
88 | {$form.html_message.label} | |
89 | </div><!-- /.crm-accordion-header --> | |
90 | <div class="crm-accordion-body"> | |
ac0a3db5 CW |
91 | <div class="helpIcon" id="helphtml"> |
92 | <input class="crm-token-selector big" data-field="html_message" /> | |
93 | {help id="id-token-html" tplFile=$tplFile isAdmin=$isAdmin editor=$editor file="CRM/Contact/Form/Task/Email.hlp"} | |
94 | </div> | |
6a488035 TO |
95 | <div class="clear"></div> |
96 | <div class='html'> | |
97 | {if $editor EQ 'textarea'} | |
149fb291 | 98 | <div class="help description">{ts}NOTE: If you are composing HTML-formatted messages, you may want to enable a Rich Text (WYSIWYG) editor (Administer » Customize Data & Screens » Display Preferences).{/ts}</div> |
6a488035 TO |
99 | {/if} |
100 | {$form.html_message.html}<br /> | |
101 | </div> | |
102 | ||
103 | <div id="editMessageDetails"> | |
104 | <div id="updateDetails" > | |
105 | {$form.updateTemplate.html} {$form.updateTemplate.label} | |
106 | </div> | |
107 | <div> | |
108 | {$form.saveTemplate.html} {$form.saveTemplate.label} | |
109 | </div> | |
110 | </div> | |
111 | ||
112 | <div id="saveDetails" class="section"> | |
113 | <div class="label">{$form.saveTemplateName.label}</div> | |
114 | <div class="content">{$form.saveTemplateName.html|crmAddClass:huge}</div> | |
115 | </div> | |
116 | ||
117 | </div><!-- /.crm-accordion-body --> | |
118 | </div><!-- /.crm-accordion-wrapper --> | |
119 | ||
120 | {include file="CRM/Mailing/Form/InsertTokens.tpl"} | |
121 | ||
122 | {literal} | |
123 | <script type="text/javascript"> | |
3cc60a06 | 124 | CRM.$(function($) { |
a7916823 CW |
125 | var $form = $('form#{/literal}{$form.formName}{literal}'); |
126 | $('#format_id', $form).on('change', function() { | |
127 | selectFormat($(this).val()); | |
128 | }); | |
6a488035 TO |
129 | }); |
130 | ||
131 | var currentWidth; | |
132 | var currentHeight; | |
133 | var currentMetric = document.getElementById('metric').value; | |
134 | showBindFormatChkBox(); | |
135 | selectPaper( document.getElementById('paper_size').value ); | |
136 | ||
6a488035 TO |
137 | function showBindFormatChkBox() |
138 | { | |
139 | var templateExists = true; | |
140 | if ( document.getElementById('template') == null || document.getElementById('template').value == '' ) { | |
141 | templateExists = false; | |
142 | } | |
a7916823 | 143 | var formatExists = !!cj('#format_id').val(); |
6a488035 TO |
144 | if ( templateExists && formatExists ) { |
145 | document.getElementById("bindFormat").style.display = "block"; | |
146 | } else if ( formatExists && document.getElementById("saveTemplate") != null && document.getElementById("saveTemplate").checked ) { | |
147 | document.getElementById("bindFormat").style.display = "block"; | |
148 | var yes = confirm( '{/literal}{$useThisPageFormat}{literal}' ); | |
149 | if ( yes ) { | |
150 | document.getElementById("bind_format").checked = true; | |
151 | } | |
152 | } else { | |
153 | document.getElementById("bindFormat").style.display = "none"; | |
154 | document.getElementById("bind_format").checked = false; | |
155 | } | |
156 | } | |
157 | ||
158 | function showUpdateFormatChkBox() | |
159 | { | |
a7916823 CW |
160 | if (cj('#format_id').val()) { |
161 | cj("#updateFormat").show(); | |
6a488035 TO |
162 | } |
163 | } | |
164 | ||
a7916823 CW |
165 | function updateFormatLabel() { |
166 | cj('.pdf-format-header-label').html(cj('#format_id option:selected').text() || cj('#format_id').attr('placeholder')); | |
6a488035 TO |
167 | } |
168 | ||
a7916823 CW |
169 | updateFormatLabel(); |
170 | ||
6a488035 TO |
171 | function selectFormat( val, bind ) |
172 | { | |
a7916823 CW |
173 | updateFormatLabel(); |
174 | if (!val) { | |
6a488035 TO |
175 | val = 0; |
176 | bind = false; | |
177 | } | |
178 | var dataUrl = {/literal}"{crmURL p='civicrm/ajax/pdfFormat' h=0 }"{literal}; | |
179 | cj.post( dataUrl, {formatId: val}, function( data ) { | |
180 | cj("#format_id").val( data.id ); | |
181 | cj("#paper_size").val( data.paper_size ); | |
182 | cj("#orientation").val( data.orientation ); | |
183 | cj("#metric").val( data.metric ); | |
184 | cj("#margin_top").val( data.margin_top ); | |
185 | cj("#margin_bottom").val( data.margin_bottom ); | |
186 | cj("#margin_left").val( data.margin_left ); | |
187 | cj("#margin_right").val( data.margin_right ); | |
188 | selectPaper( data.paper_size ); | |
a7916823 | 189 | cj("#update_format").prop({checked: false}).parent().hide(); |
6a488035 TO |
190 | document.getElementById('bind_format').checked = bind; |
191 | showBindFormatChkBox(); | |
192 | }, 'json'); | |
193 | } | |
194 | ||
195 | function selectPaper( val ) | |
196 | { | |
197 | dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal}; | |
198 | cj.post( dataUrl, {paperSizeName: val}, function( data ) { | |
199 | cj("#paper_size").val( data.name ); | |
200 | metric = document.getElementById('metric').value; | |
201 | currentWidth = convertMetric( data.width, data.metric, metric ); | |
202 | currentHeight = convertMetric( data.height, data.metric, metric ); | |
203 | updatePaperDimensions( ); | |
204 | }, 'json'); | |
205 | } | |
206 | ||
207 | function selectMetric( metric ) | |
208 | { | |
209 | convertField( 'margin_top', currentMetric, metric ); | |
210 | convertField( 'margin_bottom', currentMetric, metric ); | |
211 | convertField( 'margin_left', currentMetric, metric ); | |
212 | convertField( 'margin_right', currentMetric, metric ); | |
213 | currentWidth = convertMetric( currentWidth, currentMetric, metric ); | |
214 | currentHeight = convertMetric( currentHeight, currentMetric, metric ); | |
215 | updatePaperDimensions( ); | |
216 | } | |
217 | ||
218 | function updatePaperDimensions( ) | |
219 | { | |
220 | metric = document.getElementById('metric').value; | |
221 | width = new String( currentWidth.toFixed( 2 ) ); | |
222 | height = new String( currentHeight.toFixed( 2 ) ); | |
223 | if ( document.getElementById('orientation').value == 'landscape' ) { | |
224 | width = new String( currentHeight.toFixed( 2 ) ); | |
225 | height = new String( currentWidth.toFixed( 2 ) ); | |
226 | } | |
227 | document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric; | |
228 | currentMetric = metric; | |
229 | } | |
230 | ||
231 | function convertField( id, from, to ) | |
232 | { | |
233 | val = document.getElementById( id ).value; | |
234 | if ( val == '' || isNaN( val ) ) return; | |
235 | val = convertMetric( val, from, to ); | |
236 | val = new String( val.toFixed( 3 ) ); | |
237 | document.getElementById( id ).value = parseFloat( val ); | |
238 | } | |
239 | ||
240 | function convertMetric( value, from, to ) { | |
241 | switch( from + to ) { | |
242 | case 'incm': return value * 2.54; | |
243 | case 'inmm': return value * 25.4; | |
244 | case 'inpt': return value * 72; | |
245 | case 'cmin': return value / 2.54; | |
246 | case 'cmmm': return value * 10; | |
247 | case 'cmpt': return value * 72 / 2.54; | |
248 | case 'mmin': return value / 25.4; | |
249 | case 'mmcm': return value / 10; | |
250 | case 'mmpt': return value * 72 / 25.4; | |
251 | case 'ptin': return value / 72; | |
252 | case 'ptcm': return value * 2.54 / 72; | |
253 | case 'ptmm': return value * 25.4 / 72; | |
254 | } | |
255 | return value; | |
256 | } | |
257 | ||
258 | function showSaveDetails(chkbox) { | |
259 | var formatSelected = ( document.getElementById('format_id').value > 0 ); | |
260 | var templateSelected = ( document.getElementById('template') != null && document.getElementById('template').value > 0 ); | |
261 | if (chkbox.checked) { | |
262 | document.getElementById("saveDetails").style.display = "block"; | |
263 | document.getElementById("saveTemplateName").disabled = false; | |
264 | if ( formatSelected && ! templateSelected ) { | |
265 | document.getElementById("bindFormat").style.display = "block"; | |
266 | var yes = confirm( '{/literal}{$useSelectedPageFormat}{literal}' ); | |
267 | if ( yes ) { | |
268 | document.getElementById("bind_format").checked = true; | |
269 | } | |
270 | } | |
271 | } else { | |
272 | document.getElementById("saveDetails").style.display = "none"; | |
273 | document.getElementById("saveTemplateName").disabled = true; | |
274 | if ( ! templateSelected ) { | |
275 | document.getElementById("bindFormat").style.display = "none"; | |
276 | document.getElementById("bind_format").checked = false; | |
277 | } | |
278 | } | |
279 | } | |
280 | ||
281 | </script> | |
282 | {/literal} | |
283 |